123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- const path = require('path')
- const CompressionPlugin = require("compression-webpack-plugin");
- function resolve(dir) {
- return path.join(__dirname, dir)
- }
- module.exports = {
- publicPath: process.env.NODE_ENV === 'production' ? '/' : '/',
- lintOnSave: false,
- productionSourceMap: false,
- assetsDir: 'assets',
- // filenameHashing: false,
- // configureWebpack: () => {
- // if (process.env.NODE_ENV === 'production') {
- // return {
- // plugins: [
- // new CompressionPlugin({
- // test: /\.js$|\.html$|\.css$|\.jpg$|\.jpeg$|\.png/,
- // threshold: 10240,
- // deleteOriginalAssets: false
- // })
- // ]
- // }
- // }
- // },
- chainWebpack: config => {
- config.plugin('html')
- .tap(args => {
- args[0].title = '小世系统'
- // args[0].inlineSource = '(\.css|\.js$)'
- return args
- })
- // config.plugin('inline-source')
- // .use(require('html-webpack-inline-source-plugin'))
- config.plugins
- .delete('prefetch')
- .delete('preload')
- if (process.env.NODE_ENV === 'production') {
- // config.plugins.delete('html')
- }
- config.resolve.alias
- .set('@', path.join(__dirname, 'src'))
- 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
- .plugin('ScriptExtHtmlWebpackPlugin')
- .after('html')
- .use('script-ext-html-webpack-plugin', [{
- // `runtime` must same as runtimeChunk name. default is `runtime`
- inline: /runtime\..*\.js$/
- }])
- .end()
- config
- .optimization.splitChunks({
- chunks: 'all',
- minSize: 20000, // 允许新拆出 chunk 的最小体积,也是异步 chunk 公共模块的强制拆分体积
- maxAsyncRequests: 6, // 每个异步加载模块最多能被拆分的数量
- maxInitialRequests: 6, // 每个入口和它的同步依赖最多能被拆分的数量
- enforceSizeThreshold: 50000, // 强制执行拆分的体积阈值并忽略其他限制
- cacheGroups: {
- vue: {
- name: 'vue',
- test: /[\\/]node_modules[\\/]_?vue(.*)/,
- priority: 10,
- },
- elementUI: {
- name: 'element-ui', // split elementUI into a single package
- test: /[\\/]node_modules[\\/]_?element-ui(.*)/, // in order to adapt to cnpm
- priority: 20 // the weight needs to be larger than libs and app or it will be packaged into libs or app
- },
- echarts: {
- name: 'echarts',
- test: /[\\/]node_modules[\\/]_?echarts(.*)/,
- priority: 30,
- },
- vendors: {
- name: 'vendors',
- test: /[\\/]node_modules[\\/]/,
- priority: -10,
- chunks: 'initial' // only package third parties that are initially dependent
- },
- }
- })
- config.optimization.runtimeChunk('single')
- }
- )
- },
- devServer: {
- port: 8087,
- overlay: {
- warnings: false,
- errors: false
- },
- proxy: {
- // '/pdfjs': {
- // target: 'http://192.168.0.57:8879',
- // ws: true,
- // changeOrigin: true
- // },
- // '/file': {
- // target: 'http://192.168.0.57:8879',
- // ws: true,
- // changeOrigin: true
- // },
- '/api/v2': {
- // target: 'http://192.168.0.57:8879',
- target: 'http://192.168.1.24:8877',
- // target: 'http://139.224.24.90:8877',
- ws: true,
- changeOrigin: true
- },
- '/permission': {
- // target: 'http://192.168.0.56:8880',
- target: 'http://192.168.1.24:8871',
- // target: 'http://139.224.24.90:8871',
- ws: true,
- changeOrigin: true,
- pathRewrite:{
- '/api':''
- }
- },
- '/report':{
- target:'http://192.168.1.24:8872',
- // target:'http://139.224.24.90:8872',
- ws:true,
- changeOrigin:true
- },
- }
- }
- }
|