代码拉取完成,页面将自动刷新
'use strict'
const webpack = require('webpack');
const production = process.env.NODE_ENV === 'production';
const path = require('path');
function resolve(dir) {
return path.join(__dirname, dir);
}
// 相关配置请参考 https://cli.vuejs.org/config/
module.exports = {
publicPath: production ? './' : '/',
outputDir: 'dist',
assetsDir: 'static',
lintOnSave: process.env.NODE_ENV === 'development',
productionSourceMap: false,
// 代理服务
devServer: {
port: 9090,
// open: true, //禁用后只打开1次页面
overlay: {
warnings: false,
errors: true
}
},
configureWebpack: {
resolve: {
// 定义别名和插件位置
alias: {
'@': resolve('src'),
'api': resolve('src/api'),
'mock': resolve('src/mock'),
'mixins': resolve('src/mixins'),
'assets': resolve('src/assets'),
'config': resolve('src/config'),
'components': resolve('src/components'),
'views': resolve('src/views'),
'utils': resolve('src/utils'),
'router': resolve('src/router'),
}
},
plugins: [
// new webpack.ProvidePlugin({
// $: 'jquery',
// jQuery: 'jquery',
// 'window.jQuery': 'jquery',
// 'root.jQuery': 'jquery'
// })
],
// 外部引用
externals: {
$: 'jquery'
}
},
chainWebpack(config) {
config.plugins.delete('preload')
config.plugins.delete('prefetch')
config.module
.rule('vue')
.use('vue-loader')
.loader('vue-loader')
.tap(options => {
options.compilerOptions.preserveWhitespace = true
return options
})
.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')
.after('html')
.use('script-ext-html-webpack-plugin', [{
inline: /runtime\..*\.js$/
}])
.end()
config
.optimization.splitChunks({
chunks: 'all',
cacheGroups: {
libs: {
name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'initial'
},
elementUI: {
name: 'chunk-elementUI',
priority: 20,
test: /[\\/]node_modules[\\/]_?element-ui(.*)/
},
commons: {
name: 'chunk-commons',
test: resolve('src/components'),
minChunks: 3,
priority: 5,
reuseExistingChunk: true
}
}
})
config.optimization.runtimeChunk('single')
}
)
},
css: {
loaderOptions: {
sass: {
data: `
@import "@/styles/variables.scss";
`
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。