diff --git a/.postcssrc.js b/.postcssrc.js
index eee3e92d..09948d63 100644
--- a/.postcssrc.js
+++ b/.postcssrc.js
@@ -2,8 +2,6 @@
module.exports = {
"plugins": {
- "postcss-import": {},
- "postcss-url": {},
// to edit target browsers: use "browserslist" field in package.json
"autoprefixer": {}
}
diff --git a/package.json b/package.json
index 41929346..2a11617a 100644
--- a/package.json
+++ b/package.json
@@ -37,7 +37,6 @@
"axios": "0.18.0",
"clipboard": "1.7.1",
"codemirror": "5.39.2",
- "connect": "3.6.6",
"driver.js": "0.5.2",
"dropzone": "5.2.0",
"echarts": "4.1.0",
@@ -49,7 +48,7 @@
"jszip": "3.1.5",
"normalize.css": "7.0.0",
"nprogress": "0.2.0",
- "path-to-regexp": "^2.4.0",
+ "path-to-regexp": "2.4.0",
"screenfull": "3.3.3",
"showdown": "1.8.6",
"simplemde": "1.11.2",
@@ -64,30 +63,21 @@
"xlsx": "^0.11.16"
},
"devDependencies": {
- "@babel/core": "7.0.0",
"@babel/register": "7.0.0",
- "@vue/babel-helper-vue-jsx-merge-props": "0.1.0",
- "@vue/cli-plugin-babel": "^3.0.5",
- "@vue/cli-plugin-eslint": "^3.0.5",
- "@vue/cli-plugin-unit-mocha": "^3.0.5",
- "@vue/cli-service": "^3.0.5",
- "@vue/eslint-config-standard": "^3.0.5",
- "@vue/test-utils": "^1.0.0-beta.25",
- "autoprefixer": "8.5.0",
- "babel-plugin-istanbul": "^4.1.6",
+ "@vue/cli-plugin-babel": "3.0.5",
+ "@vue/cli-plugin-eslint": "3.0.5",
+ "@vue/cli-plugin-unit-jest": "3.0.5",
+ "@vue/cli-service": "3.0.5",
+ "@vue/test-utils": "1.0.0-beta.25",
+ "babel-core": "7.0.0-bridge.0",
+ "babel-jest": "23.6.0",
"husky": "0.14.3",
"lint-staged": "7.2.2",
"mockjs": "1.0.1-beta3",
- "node-notifier": "5.2.1",
"node-sass": "^4.7.2",
- "optimize-css-assets-webpack-plugin": "5.0.0",
- "postcss-import": "11.1.0",
- "postcss-loader": "2.1.6",
- "postcss-url": "7.3.2",
"sass-loader": "7.0.3",
"script-ext-html-webpack-plugin": "2.0.1",
"script-loader": "0.7.2",
- "shelljs": "0.8.2",
"svg-sprite-loader": "3.8.0",
"svgo": "1.0.5",
"vue-template-compiler": "2.5.17"
diff --git a/public/index.html b/public/index.html
index adb0ecc0..a2fac6d6 100644
--- a/public/index.html
+++ b/public/index.html
@@ -6,7 +6,7 @@
-
vue-element-admin
+ <%= webpackConfig.name %>
diff --git a/vue.config.js b/vue.config.js
index d4f047fa..3cf98e60 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -1,18 +1,37 @@
'use strict'
-require('@babel/register')
const path = require('path')
-const bodyParser = require('body-parser')
function resolve(dir) {
return path.join(__dirname, dir)
}
+const port = 9527 // TODO: change to Settings
+
+// Explanation of each configuration item You can find it in https://cli.vuejs.org/config/
module.exports = {
+ /**
+ * You can set by yourself according to actual condition
+ * You will need to set this if you plan to deploy your site under a sub path,
+ * for example GitHub pages. If you plan to deploy your site to https://foo.github.io/bar/,
+ * then assetsPublicPath should be set to "/bar/".
+ * In most cases please use '/' !!!
+ * Detail https://cli.vuejs.org/config/#baseurl
+ */
+ baseUrl: '/',
+ outputDir: 'dist',
+ assetsDir: 'static',
+ lintOnSave: process.env.NODE_ENV !== 'production',
+ productionSourceMap: false,
devServer: {
+ port: port,
open: true,
+ overlay: {
+ warnings: false,
+ errors: true
+ },
proxy: {
'/api': {
- target: 'http://localhost:8080/mock',
+ target: `http://localhost:${port}/mock`,
changeOrigin: true,
pathRewrite: {
'^/api': ''
@@ -20,6 +39,9 @@ module.exports = {
}
},
after(app) {
+ console.log('apple')
+ const bodyParser = require('body-parser')
+ require('@babel/register')
// parse app.body
// http://expressjs.com/en/4x/api.html#req.body
app.use(bodyParser.json())
@@ -33,28 +55,74 @@ module.exports = {
}
},
configureWebpack: {
+ // We provide the app's title in Webpack's name field, so that
+ // it can be accessed in index.html to inject the correct title.
+ name: 'vue-element-admin', // TODO: change to Settings
resolve: {
alias: {
- '$@': resolve('src/components')
+ '@': resolve('src')
}
- },
- module: {
- rules: [
- {
- test: /\.svg$/,
- loader: 'svg-sprite-loader',
- include: [resolve('src/icons')],
- options: {
- symbolId: 'icon-[name]'
- }
- }
- ]
}
},
chainWebpack(config) {
+ config.plugins.delete('preload')// TODO: need test
+ config.plugins.delete('prefetch')// TODO: need test
config.module
.rule('svg')
.exclude.add(resolve('src/icons'))
.end()
+ config.module
+ .rule('icons')
+ .test(/\.svg$/)
+ .include.add(resolve('src/icons'))
+ .end()
+ .use('svg-sprite-loader')
+ .loader('svg-sprite-loader')
+ .options({
+ symbolId: 'icon-[name]'
+ })
+ .end()
+
+ config
+ .when(process.env.NODE_ENV === 'development',
+ config => config.devtool('cheap-source-map')
+ )
+
+ config
+ .when(process.env.NODE_ENV !== 'development',
+ config => {
+ config
+ .plugin('ScriptExtHtmlWebpackPlugin')
+ .use('script-ext-html-webpack-plugin', [{
+ // `runtime` must same as runtimeChunk name. default is `runtime`
+ inline: /runtime\..*\.js$/
+ }])
+ config
+ .optimization.splitChunks({
+ chunks: 'all',
+ cacheGroups: {
+ libs: {
+ name: 'chunk-libs',
+ test: /[\\/]node_modules[\\/]/,
+ priority: 10,
+ chunks: 'initial' // 只打包初始时依赖的第三方
+ },
+ elementUI: {
+ name: 'chunk-elementUI', // 单独将 elementUI 拆包
+ priority: 20, // 权重要大于 libs 和 app 不然会被打包进 libs 或者 app
+ test: /[\\/]node_modules[\\/]element-ui[\\/]/
+ },
+ commons: {
+ name: 'chunk-commons',
+ test: resolve('src/components'), // 可自定义拓展你的规则
+ minChunks: 3, // 最小公用次数
+ priority: 5,
+ reuseExistingChunk: true
+ }
+ }
+ })
+ config.optimization.runtimeChunk('single')
+ }
+ )
}
}