|
@@ -1,27 +1,16 @@
|
|
|
'use strict'
|
|
|
const path = require('path')
|
|
|
const defaultSettings = require('./src/settings.js')
|
|
|
-// const CompressionWebpackPlugin = require('compression-webpack-plugin')
|
|
|
|
|
|
function resolve(dir) {
|
|
|
return path.join(__dirname, dir)
|
|
|
}
|
|
|
|
|
|
const name = defaultSettings.title || 'vue Admin Template' // page title
|
|
|
-// If your port is set to 80,
|
|
|
-// use administrator privileges to execute the command line.
|
|
|
-// For example, Mac: sudo npm run
|
|
|
+
|
|
|
const port = 9528 // dev port
|
|
|
|
|
|
-// All configuration item explanations can be find in https://cli.vuejs.org/config/
|
|
|
module.exports = {
|
|
|
- /**
|
|
|
- * You will need to set publicPath 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 publicPath should be set to "/bar/".
|
|
|
- * In most cases please use '/' !!!
|
|
|
- * Detail: https://cli.vuejs.org/config/#publicpath
|
|
|
- */
|
|
|
publicPath: '/',
|
|
|
outputDir: 'dist',
|
|
|
assetsDir: 'static',
|
|
@@ -36,8 +25,6 @@ module.exports = {
|
|
|
},
|
|
|
disableHostCheck: true, // webpack4.0 开启热更新
|
|
|
proxy: {
|
|
|
- // change xxx-api/login => mock/login
|
|
|
- // detail: https://cli.vuejs.org/config/#devserver-proxy
|
|
|
[process.env.VUE_APP_BASE_API]: {
|
|
|
target: `http://127.0.0.1:${port}/mock`,
|
|
|
changeOrigin: true,
|
|
@@ -46,28 +33,24 @@ module.exports = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // after: require('./mock/mock-server.js')
|
|
|
+ },
|
|
|
+ performance: { // 性能设置
|
|
|
+ hints: 'warning',
|
|
|
+ maxEntrypointSize: 500000,
|
|
|
+ maxAssetSize: 300000
|
|
|
},
|
|
|
configureWebpack: {
|
|
|
- // 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: name,
|
|
|
resolve: {
|
|
|
alias: {
|
|
|
'@': resolve('src')
|
|
|
}
|
|
|
}
|
|
|
- // plugins: [
|
|
|
- // new CompressionWebpackPlugin({ // 构建压缩加速
|
|
|
- // test: /\.js$|\.html$|\.css/
|
|
|
- // })
|
|
|
- // ]
|
|
|
},
|
|
|
chainWebpack(config) {
|
|
|
config.plugins.delete('preload') // TODO: need test
|
|
|
config.plugins.delete('prefetch') // TODO: need test
|
|
|
|
|
|
- // set svg-sprite-loader
|
|
|
config.module
|
|
|
.rule('svg')
|
|
|
.exclude.add(resolve('src/icons'))
|
|
@@ -84,7 +67,6 @@ module.exports = {
|
|
|
})
|
|
|
.end()
|
|
|
|
|
|
- // set preserveWhitespace
|
|
|
config.module
|
|
|
.rule('vue')
|
|
|
.use('vue-loader')
|
|
@@ -96,7 +78,6 @@ module.exports = {
|
|
|
.end()
|
|
|
|
|
|
config
|
|
|
- // https://webpack.js.org/configuration/devtool/#development
|
|
|
.when(process.env.NODE_ENV === 'development',
|
|
|
config => config.devtool('cheap-source-map')
|
|
|
)
|
|
@@ -108,7 +89,6 @@ module.exports = {
|
|
|
.plugin('ScriptExtHtmlWebpackPlugin')
|
|
|
.after('html')
|
|
|
.use('script-ext-html-webpack-plugin', [{
|
|
|
- // `runtime` must same as runtimeChunk name. default is `runtime`
|
|
|
inline: /runtime\..*\.js$/
|
|
|
}])
|
|
|
.end()
|
|
@@ -116,42 +96,12 @@ module.exports = {
|
|
|
.optimization.splitChunks({
|
|
|
chunks: 'all',
|
|
|
cacheGroups: {
|
|
|
- styles: {
|
|
|
- name: 'styles',
|
|
|
- test: /\.css$/,
|
|
|
- chunks: 'all',
|
|
|
- enforce: true // 忽略splitChunks的其他配置,强制将匹配到的缓存组中的文件合并为一个styles.css文件
|
|
|
- },
|
|
|
libs: {
|
|
|
name: 'chunk-libs',
|
|
|
test: /[\\/]node_modules[\\/]/,
|
|
|
priority: -10,
|
|
|
chunks: 'initial' // only package third parties that are initially dependent
|
|
|
}
|
|
|
- // elementUI: {
|
|
|
- // name: 'chunk-elementUI', // split elementUI into a single package
|
|
|
- // priority: 15, // the weight needs to be larger than libs and app or it will be packaged into libs or app
|
|
|
- // test: /[\\/]node_modules[\\/]element-ui[\\/]/, // in order to adapt to cnpm
|
|
|
- // chunks: 'all',
|
|
|
- // reuseExistingChunk: true,
|
|
|
- // enforce: true
|
|
|
- // },
|
|
|
- // echarts: {
|
|
|
- // name: 'chunk-echarts',
|
|
|
- // test: /[\\/]node_modules[\\/]echarts[\\/]/,
|
|
|
- // chunks: 'all',
|
|
|
- // priority: 10,
|
|
|
- // reuseExistingChunk: true,
|
|
|
- // enforce: true
|
|
|
- // },
|
|
|
- // demo: {
|
|
|
- // name: 'chunk-demo',
|
|
|
- // test: /[\\/]src[\\/]views[\\/]/,
|
|
|
- // chunks: 'all',
|
|
|
- // priority: 20,
|
|
|
- // reuseExistingChunk: true,
|
|
|
- // enforce: true
|
|
|
- // }
|
|
|
}
|
|
|
})
|
|
|
config.optimization.runtimeChunk('single')
|