From 41741f1882c019edac15b1a05f51b72e5af069f7 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 7 Feb 2020 07:55:09 +0100 Subject: viewer: project optimization for faster init, and a better Visual Studio Code environnement --- viewer/.env | 1 + viewer/.gitignore | 2 +- viewer/.vscode/launch.json | 19 +++++++++++++++++++ viewer/.vscode/tasks.json | 22 ++++++++++++++++++++++ viewer/src/main.ts | 18 ++++++++++-------- viewer/tsconfig.json | 6 +++--- viewer/visualstudio.code-workspace | 11 +++++++++-- viewer/vue.config.js | 5 ++++- 8 files changed, 69 insertions(+), 15 deletions(-) create mode 100644 viewer/.vscode/launch.json create mode 100644 viewer/.vscode/tasks.json diff --git a/viewer/.env b/viewer/.env index 9092dea..959477b 100644 --- a/viewer/.env +++ b/viewer/.env @@ -2,3 +2,4 @@ VUE_APP_I18N_LOCALE=en VUE_APP_I18N_FALLBACK_LOCALE=en VUE_APP_EXAMPLE_PROJECT=../example/out/ VUE_APP_DATA_URL=gallery/ +VUE_APP_DEVSERVER_PORT=8085 diff --git a/viewer/.gitignore b/viewer/.gitignore index 12a8306..f1ab425 100644 --- a/viewer/.gitignore +++ b/viewer/.gitignore @@ -13,7 +13,7 @@ yarn-error.log* # Editor directories and files .idea -.vscode +.vscode/settings.json *.suo *.ntvs* *.njsproj diff --git a/viewer/.vscode/launch.json b/viewer/.vscode/launch.json new file mode 100644 index 0000000..d7995e5 --- /dev/null +++ b/viewer/.vscode/launch.json @@ -0,0 +1,19 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "chrome", + "request": "launch", + "name": "vuejs: chrome", + "url": "http://127.0.0.1:8085", + "webRoot": "${workspaceFolder}/src", + "breakOnLoad": true, + "sourceMapPathOverrides": { + "webpack:///./src/*": "${webRoot}/*" + } + } + ] +} \ No newline at end of file diff --git a/viewer/.vscode/tasks.json b/viewer/.vscode/tasks.json new file mode 100644 index 0000000..3c02098 --- /dev/null +++ b/viewer/.vscode/tasks.json @@ -0,0 +1,22 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "build", + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "type": "npm", + "script": "serve", + "problemMatcher": [ + "$tsc" + ] + } + ] +} \ No newline at end of file diff --git a/viewer/src/main.ts b/viewer/src/main.ts index a8ff322..bc005c5 100644 --- a/viewer/src/main.ts +++ b/viewer/src/main.ts @@ -19,21 +19,23 @@ import Vue from "vue"; import "@/assets/scss/global.scss"; -import "@/components" -import "@/plugins/fontawesome"; -import "@/plugins/buefy"; -import "@/plugins/lazyimage"; -import "@/plugins/dragscroll"; import store from '@/store' import i18n from "@/plugins/i18n"; import router from "@/plugins/router"; -import MainLayout from "@/views/MainLayout.vue"; - Vue.config.productionTip = false; +import(/* webpackChunkName: "ui" */ "@/plugins/buefy"); +import(/* webpackChunkName: "ui" */ "@/components"); +import(/* webpackChunkName: "ui" */ "@/plugins/lazyimage"); +import(/* webpackChunkName: "ui" */ "@/plugins/dragscroll"); +import(/* webpackChunkName: "ui" */ "@/plugins/fontawesome"); +const MainLayout = () => import(/* webpackChunkName: "ui" */ "@/views/MainLayout.vue"); + new Vue({ router, i18n, store, render: h => h(MainLayout) -}).$mount("#ldgallery"); +}).$mount("#ldgallery") + + diff --git a/viewer/tsconfig.json b/viewer/tsconfig.json index 061c46c..38e14fa 100644 --- a/viewer/tsconfig.json +++ b/viewer/tsconfig.json @@ -14,11 +14,13 @@ "types": [ "webpack-env", "webpack", - "webpack-env" ], "paths": { "@/*": [ "src/*" + ], + "components/*": [ + "src/components/*" ] }, "lib": [ @@ -32,8 +34,6 @@ "src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", - "tests/**/*.ts", - "tests/**/*.tsx" ], "exclude": [ "node_modules" diff --git a/viewer/visualstudio.code-workspace b/viewer/visualstudio.code-workspace index 67b3ba9..6935f4f 100644 --- a/viewer/visualstudio.code-workspace +++ b/viewer/visualstudio.code-workspace @@ -6,9 +6,16 @@ ], "settings": { "editor.formatOnSave": true, + "editor.wordBasedSuggestions": false, "javascript.format.semicolons": "insert", "typescript.disableAutomaticTypeAcquisition": true, - "vue-i18n-ally.localesPaths": "src/locales", "vue-i18n-ally.keystyle": "flat", + "i18n-ally.localesPaths": "src/locales", } -} \ No newline at end of file +} +// Recommended Visual Studio Code extensions: +// - Vetur +// - i18n Ally +// - SCSS Everywhere +// - Debugger for Chrome +// - vscode-icons diff --git a/viewer/vue.config.js b/viewer/vue.config.js index 67b7461..1ef0f9b 100644 --- a/viewer/vue.config.js +++ b/viewer/vue.config.js @@ -27,9 +27,12 @@ module.exports = { enableInSFC: false, }, }, + configureWebpack: { + devtool: 'source-map' + }, productionSourceMap: false, devServer: { - port: 8085, + port: process.env.VUE_APP_DEVSERVER_PORT, serveIndex: true, before: (app, server, compiler) => { app.get(`/${process.env.VUE_APP_DATA_URL}*`, (req, res) => { -- cgit v1.2.3