2023-11-02 12:12:37 +00:00
|
|
|
const { defineConfig } = require('@vue/cli-service');
|
2023-12-28 06:31:33 +00:00
|
|
|
const Webpack = require('webpack');
|
2023-12-01 08:13:51 +00:00
|
|
|
// 分析打包时间
|
2023-12-28 06:31:33 +00:00
|
|
|
const SpeedMeasureWebpackPlugin = require('speed-measure-webpack-plugin');
|
2023-11-02 12:12:37 +00:00
|
|
|
|
|
|
|
module.exports = defineConfig({
|
|
|
|
transpileDependencies: true,
|
|
|
|
lintOnSave: false,
|
|
|
|
pages: {
|
|
|
|
management: {
|
|
|
|
entry: `src/management/main.js`,
|
|
|
|
template: 'public/management.html',
|
|
|
|
filename: `management.html`,
|
|
|
|
title: '问卷调研',
|
|
|
|
},
|
|
|
|
render: {
|
|
|
|
entry: `src/render/main.js`,
|
|
|
|
template: 'public/render.html',
|
|
|
|
filename: `render.html`,
|
|
|
|
title: '问卷调研',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
css: {
|
|
|
|
loaderOptions: {
|
|
|
|
sass: {
|
|
|
|
additionalData: `@import "./src/management/styles/variable.scss";`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
devServer: {
|
|
|
|
proxy: {
|
|
|
|
'/api': {
|
2023-12-28 06:31:33 +00:00
|
|
|
target: 'http://127.0.0.1:3000',
|
2023-11-02 12:12:37 +00:00
|
|
|
changeOrigin: true,
|
|
|
|
},
|
|
|
|
},
|
2023-11-13 20:21:18 +00:00
|
|
|
setupMiddlewares(middlewares, devServer) {
|
|
|
|
if (!devServer) {
|
|
|
|
throw new Error('webpack-dev-server is not defined');
|
|
|
|
}
|
|
|
|
devServer.app.get('/', function (req, res) {
|
|
|
|
res.redirect('/management');
|
|
|
|
});
|
|
|
|
return middlewares;
|
|
|
|
},
|
|
|
|
open: true,
|
2023-11-02 12:12:37 +00:00
|
|
|
},
|
2023-12-01 08:13:51 +00:00
|
|
|
configureWebpack: {
|
2023-12-28 06:31:33 +00:00
|
|
|
plugins: [
|
|
|
|
new Webpack.IgnorePlugin({
|
|
|
|
resourceRegExp: /^\.\/locale$/,
|
|
|
|
contextRegExp: /moment$/,
|
|
|
|
}),
|
|
|
|
],
|
2023-12-01 08:13:51 +00:00
|
|
|
},
|
2023-11-02 12:12:37 +00:00
|
|
|
chainWebpack: (config) => {
|
|
|
|
config.module
|
|
|
|
.rule('js')
|
|
|
|
.test(/\.jsx?$/)
|
2023-12-28 06:31:33 +00:00
|
|
|
.exclude.add(/node_modules/)
|
|
|
|
.end()
|
2023-11-02 12:12:37 +00:00
|
|
|
.use('babel-loader')
|
|
|
|
.loader('babel-loader')
|
|
|
|
.end();
|
2023-12-28 06:31:33 +00:00
|
|
|
|
2023-11-02 12:12:37 +00:00
|
|
|
config.optimization.splitChunks({
|
|
|
|
cacheGroups: {
|
|
|
|
setterWidgets: {
|
2023-12-01 08:13:51 +00:00
|
|
|
name: 'chunk-setterWidgets',
|
|
|
|
test: /\/materials\/setters[\\/]/,
|
2023-11-02 12:12:37 +00:00
|
|
|
chunks: 'async',
|
|
|
|
enforce: true,
|
|
|
|
},
|
|
|
|
materialWidgets: {
|
2023-12-01 08:13:51 +00:00
|
|
|
name: 'chunk-materialWidgets',
|
|
|
|
test: /\/materials\/questions[\\/]/,
|
2023-11-02 12:12:37 +00:00
|
|
|
chunks: 'async',
|
|
|
|
enforce: true,
|
|
|
|
},
|
2023-12-01 08:13:51 +00:00
|
|
|
commonEditor: {
|
|
|
|
name: 'chunk-commonEditor',
|
|
|
|
test: /\/common\/Editor[\\/]/,
|
|
|
|
enforce: true,
|
|
|
|
},
|
|
|
|
element: {
|
|
|
|
name: 'chunk-element-ui',
|
|
|
|
test: /[\\/]node_modules[\\/]element-ui[\\/]/,
|
2023-12-28 06:31:33 +00:00
|
|
|
chunks: 'all',
|
2023-12-01 08:13:51 +00:00
|
|
|
priority: 3,
|
|
|
|
reuseExistingChunk: true,
|
2023-12-28 06:31:33 +00:00
|
|
|
enforce: true,
|
2023-12-01 08:13:51 +00:00
|
|
|
},
|
|
|
|
moment: {
|
|
|
|
name: 'chunk-moment',
|
|
|
|
test: /[\\/]node_modules[\\/]moment[\\/]/,
|
2023-12-28 06:31:33 +00:00
|
|
|
chunks: 'all',
|
2023-12-01 08:13:51 +00:00
|
|
|
priority: 3,
|
|
|
|
reuseExistingChunk: true,
|
2023-12-28 06:31:33 +00:00
|
|
|
enforce: true,
|
2023-12-01 08:13:51 +00:00
|
|
|
},
|
|
|
|
'@wangeditor': {
|
|
|
|
name: 'chunk-wangeditor',
|
|
|
|
test: /[\\/]node_modules[\\/]@wangeditor[\\/]/,
|
2023-12-28 06:31:33 +00:00
|
|
|
chunks: 'all',
|
2023-12-01 08:13:51 +00:00
|
|
|
priority: 3,
|
|
|
|
reuseExistingChunk: true,
|
2023-12-28 06:31:33 +00:00
|
|
|
enforce: true,
|
2023-12-01 08:13:51 +00:00
|
|
|
},
|
|
|
|
common: {
|
|
|
|
//抽取所有入口页面都需要的公共chunk
|
2023-12-28 06:31:33 +00:00
|
|
|
name: 'chunk-common',
|
|
|
|
chunks: 'initial',
|
2023-12-01 08:13:51 +00:00
|
|
|
minChunks: 2,
|
|
|
|
maxInitialRequests: 5,
|
|
|
|
minSize: 0,
|
|
|
|
priority: 1,
|
|
|
|
reuseExistingChunk: true,
|
2023-12-28 06:31:33 +00:00
|
|
|
enforce: true,
|
|
|
|
},
|
2023-11-02 12:12:37 +00:00
|
|
|
},
|
|
|
|
});
|
2023-12-28 06:31:33 +00:00
|
|
|
config.plugin('speed').use(SpeedMeasureWebpackPlugin);
|
2023-11-02 12:12:37 +00:00
|
|
|
},
|
|
|
|
});
|