From e41039922c0361426af697225c58d9f494b27293 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 22 Oct 2021 21:43:01 +0200 Subject: [PATCH] Migrate to vite Signed-off-by: Thomas Citharel --- config/config.exs | 9 + config/dev.exs | 8 +- js/package.json | 55 +- js/public/index.html | 39 +- js/src/App.vue | 23 +- js/src/common.scss | 6 +- js/src/components/Event/DateCalendarIcon.vue | 13 - js/src/components/Event/EventFullDate.vue | 19 - .../components/Event/ParticipationButton.vue | 25 - js/src/components/Footer.vue | 2 +- .../Map/Vue2LeafletLocateControl.vue | 4 +- js/src/components/Report/ReportCard.vue | 5 - js/src/env.d.ts | 5 + js/src/main.ts | 4 + js/src/plugins/dateFns.ts | 8 +- js/src/registerServiceWorker.ts | 4 +- js/src/utils/i18n.ts | 5 +- js/src/variables.scss | 6 +- js/src/views/Group/Group.vue | 2 +- js/src/views/Home.vue | 2 +- js/src/views/PageNotFound.vue | 4 - js/src/vue-apollo.ts | 2 +- js/tests/unit/svgTransform.ts | 15 - js/tsconfig.json | 2 +- js/vite.config.js | 39 + js/vue.config.js | 31 - js/yarn.lock | 7857 ++--------------- lib/service/metadata/instance.ex | 5 + lib/web/endpoint.ex | 2 +- lib/web/telemetry.ex | 71 + lib/web/{mobilizon_web.ex => web.ex} | 0 mix.exs | 9 +- mix.lock | 5 + 33 files changed, 1065 insertions(+), 7221 deletions(-) create mode 100644 js/src/env.d.ts delete mode 100644 js/tests/unit/svgTransform.ts create mode 100644 js/vite.config.js delete mode 100644 js/vue.config.js create mode 100644 lib/web/telemetry.ex rename lib/web/{mobilizon_web.ex => web.ex} (100%) diff --git a/config/config.exs b/config/config.exs index bec1c440a..146859e9a 100644 --- a/config/config.exs +++ b/config/config.exs @@ -116,6 +116,15 @@ config :mobilizon, Mobilizon.Web.Email.Mailer, # can be `true` no_mx_lookups: false +config :esbuild, + version: "0.12.18", + default: [ + args: + ~w(src/main.js --bundle --target=es2016 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*), + cd: Path.expand("../js", __DIR__), + env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)} + ] + # Configures Elixir's Logger config :logger, :console, backends: [:console], diff --git a/config/dev.exs b/config/dev.exs index 291bdc463..c933ee200 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -15,13 +15,7 @@ config :mobilizon, Mobilizon.Web.Endpoint, check_origin: false, watchers: [ node: [ - "node_modules/webpack/bin/webpack.js", - "--mode", - "development", - "--watch", - "--watch-options-stdin", - "--config", - "node_modules/@vue/cli-service/webpack.config.js", + "node_modules/.bin/vite", cd: Path.expand("../js", __DIR__) ] ] diff --git a/js/package.json b/js/package.json index 7f60c427d..ce2bd2e10 100644 --- a/js/package.json +++ b/js/package.json @@ -3,13 +3,9 @@ "version": "1.3.2", "private": true, "scripts": { - "serve": "vue-cli-service serve", - "build": "yarn run build:assets && yarn run build:pictures", - "test:unit": "LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 TZ=UTC vue-cli-service test:unit", - "test:e2e": "vue-cli-service test:e2e", - "lint": "vue-cli-service lint", - "build:assets": "vue-cli-service build", - "build:pictures": "bash ./scripts/build/pictures.sh" + "dev": "tsc --noEmit && vite", + "build": "vite build", + "serve": "vite preview" }, "dependencies": { "@absinthe/socket": "^0.2.1", @@ -35,8 +31,8 @@ "apollo-absinthe-upload-link": "^1.5.0", "blurhash": "^1.1.3", "buefy": "^0.9.0", + "bulma": "^0.9.3", "bulma-divider": "^0.2.0", - "core-js": "^3.6.4", "date-fns": "^2.16.0", "date-fns-tz": "^1.1.6", "graphql": "^15.0.0", @@ -53,59 +49,40 @@ "tippy.js": "^6.2.3", "unfetch": "^4.2.0", "v-tooltip": "^2.1.3", - "vue": "^2.6.11", + "vue": "^2.6.14", "vue-class-component": "^7.2.3", "vue-i18n": "^8.14.0", "vue-meta": "^2.3.1", "vue-property-decorator": "^9.0.0", - "vue-router": "^3.1.6", + "vue-router": "^3.5.2", "vue-scrollto": "^2.17.1", "vue2-leaflet": "^2.0.3", "vuedraggable": "^2.24.3" }, "devDependencies": { + "@rollup/plugin-dynamic-import-vars": "^1.4.1", "@types/jest": "^27.0.2", "@types/leaflet": "^1.5.2", "@types/leaflet.locatecontrol": "^0.60.7", "@types/lodash": "^4.14.141", "@types/ngeohash": "^0.6.2", + "@types/node": "^16.11.3", "@types/phoenix": "^1.5.2", "@types/prosemirror-inputrules": "^1.0.2", "@types/prosemirror-model": "^1.7.2", "@types/prosemirror-state": "^1.2.4", "@types/prosemirror-view": "^1.11.4", - "@typescript-eslint/eslint-plugin": "^4.18.0", - "@typescript-eslint/parser": "^4.18.0", - "@vue/cli-plugin-babel": "~5.0.0-beta.6", - "@vue/cli-plugin-e2e-cypress": "~5.0.0-beta.6", - "@vue/cli-plugin-eslint": "~5.0.0-beta.6", - "@vue/cli-plugin-pwa": "~5.0.0-beta.6", - "@vue/cli-plugin-router": "~5.0.0-beta.6", - "@vue/cli-plugin-typescript": "~5.0.0-beta.6", - "@vue/cli-plugin-unit-jest": "~5.0.0-beta.6", - "@vue/cli-service": "~5.0.0-beta.6", - "@vue/eslint-config-prettier": "^6.0.0", - "@vue/eslint-config-typescript": "^7.0.0", - "@vue/test-utils": "^1.1.0", + "@vue/test-utils": "^1.2.2", "@vue/vue2-jest": "^27.0.0-alpha.2", - "cypress": "^8.3.0", - "eslint": "^7.20.0", - "eslint-plugin-cypress": "^2.10.3", - "eslint-plugin-import": "^2.20.2", - "eslint-plugin-prettier": "^4.0.0", - "eslint-plugin-vue": "^7.6.0", "flush-promises": "^1.0.2", - "jest": "^27.1.0", - "jest-junit": "^13.0.0", "mock-apollo-client": "^1.1.0", "prettier": "^2.2.1", - "prettier-eslint": "^13.0.0", - "sass": "^1.34.1", - "sass-loader": "^12.0.0", - "ts-jest": "27", - "typescript": "~4.4.3", - "vue-i18n-extract": "^2.0.4", - "vue-template-compiler": "^2.6.11", - "webpack-cli": "^4.7.0" + "sass": "^1.43.3", + "typescript": "^4.3.2", + "vite": "^2.6.4", + "vite-plugin-html": "^2.1.1", + "vite-plugin-pwa": "^0.11.3", + "vite-plugin-vue2": "^1.9.0", + "vue-template-compiler": "^2.6.14" } } diff --git a/js/public/index.html b/js/public/index.html index 6535abfcd..78519c853 100644 --- a/js/public/index.html +++ b/js/public/index.html @@ -1,22 +1,25 @@ - - - - - - - - - +
+ + + + \ No newline at end of file diff --git a/js/src/App.vue b/js/src/App.vue index 237ab57d9..3e48a46f4 100644 --- a/js/src/App.vue +++ b/js/src/App.vue @@ -244,8 +244,27 @@ export default class App extends Vue { @import "variables"; /* Icons */ -$mdi-font-path: "~@mdi/font/fonts"; -@import "~@mdi/font/scss/materialdesignicons"; +@import "node_modules/@mdi/font/scss/variables"; +@import "node_modules/@mdi/font/scss/functions"; + +@font-face { + font-family: '#{$mdi-font-name}'; + src: url('../node_modules/@mdi/font/materialdesignicons-webfont.eot'); + src: url('../node_modules/@mdi/font/materialdesignicons-webfont.eot?#iefix') format('embedded-opentype'), + url('../node_modules/@mdi/font/materialdesignicons-webfont.woff2') format('woff2'), + url('../node_modules/@mdi/font/materialdesignicons-webfont.woff') format('woff'), + url('../node_modules/@mdi/font/materialdesignicons-webfont.ttf') format('truetype'); + font-weight: normal; + font-style: normal; +} + + +@import "node_modules/@mdi/font/scss/core"; +@import "node_modules/@mdi/font/scss/icons"; +@import "node_modules/@mdi/font/scss/extras"; +@import "node_modules/@mdi/font/scss/animated"; + + @import "common"; diff --git a/js/src/common.scss b/js/src/common.scss index 30160e383..6e2f8b088 100644 --- a/js/src/common.scss +++ b/js/src/common.scss @@ -1,8 +1,8 @@ @import "variables.scss"; -@import "~bulma"; -@import "~bulma-divider"; -@import "~buefy/src/scss/buefy"; +@import "node_modules/bulma/bulma.sass"; +@import "node_modules/bulma-divider/dist/css/bulma-divider.sass"; +@import "node_modules/buefy/src/scss/buefy"; @import "styles/vue-announcer.scss"; @import "styles/vue-skip-to.scss"; diff --git a/js/src/components/Event/DateCalendarIcon.vue b/js/src/components/Event/DateCalendarIcon.vue index bd87863d1..9a701a910 100644 --- a/js/src/components/Event/DateCalendarIcon.vue +++ b/js/src/components/Event/DateCalendarIcon.vue @@ -1,16 +1,3 @@ - -### Example -```vue - -``` - -```vue - -``` - -