123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- const CompressionPlugin = require('compression-webpack-plugin');
- const webpack = require('webpack');
- const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
- module.exports = {
- publicPath: process.env.NODE_ENV === 'production' ? '' : '/',
- productionSourceMap: false,
- lintOnSave: false,
- chainWebpack: config => {
- if (process.env.NODE_ENV === 'production') {
- if (process.env.npm_config_report) {
- config
- .plugin('webpack-bundle-analyzer')
- .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
- }
- config.plugins.delete('prefetch');
- }
- },
- configureWebpack: config => {
- if (process.env.NODE_ENV === 'production') {
- config.optimization = {
- splitChunks: {
- chunks: "all", //async异步代码分割 initial同步代码分割 all同步异步分割都开启
- minSize: 10000, //字节 引入的文件大于30kb才进行分割
- // minChunks: 2, //模块至少使用次数
- // maxAsyncRequests: 25, //同时加载的模块数量最多是5个,只分割出同时引入的前5个文件
- // maxInitialRequests: 30, //首页加载的时候引入的文件最多3个
- automaticNameDelimiter: '-', //缓存组和生成文件名称之间的连接符
- // name: true, //缓存组里面的filename生效,覆盖默认命名
- cacheGroups: {
- // vue: {
- // name: "vue",
- // test: /[\\/]node_modules[\\/]vue[\\/]/,
- // test: /[\\/]node_modules[\\/]vue[\\/]/,
- // priority: -10
- // },
- // vuex: {
- // name: 'vuex',
- // test: /[\\/]node_modules[\\/]vuex[\\/]/,
- // priority: -10
- // },
- // 'vue-router': {
- // name: 'vue-router',
- // test: /[\\/]node_modules[\\/]vue-router[\\/]/,
- // priority: -10
- // },
- // 'element-ui': {
- // name: 'element-ui',
- // test: /[\\/]node_modules[\\/]element-ui[\\/]/,
- // priority: -10
- // },
- // vendors: {
- // test: /[\\\/]node_modules[\\\/]/,
- // priority: -20
- // },
- }
- }
- }
- // return {
- // plugins: [
- // new CompressionPlugin({
- // test: /\.js$|\.html$|\.css$/,
- // threshold: 10240,
- // deleteOriginalAssets: false,
- // }),
- // new webpack.optimize.MinChunkSizePlugin({
- // minChunkSize: 10000 // Minimum number of characters
- // }),
- // new WebpackLifeCyclePlugin(),
- // new BundleAnalyzerPlugin()
- // ]
- // }
- // config.plugins = [
- // new CompressionPlugin({
- // test: /\.js$|\.html$|\.css$/,
- // threshold: 10240,
- // deleteOriginalAssets: true,
- // }),
- // new webpack.optimize.MinChunkSizePlugin({
- // minChunkSize: 10000 // Minimum number of characters
- // }),
- // new WebpackLifeCyclePlugin(),
- // // new BundleAnalyzerPlugin()
- // ]
- }
- },
- parallel: true,
- devServer: {
- proxy: {
- '/': {
- // target: 'http://192.168.2.145:9600/spfm',
- // target: 'http://192.168.2.149:9600',
- // target: 'http://10.64.42.70:8088/',
- target: 'http://114.215.71.182:29600/',
- // target: 'http://192.168.2.135:9600/',
- // target: 'http://192.168.2.169:9600/',
- // target: 'http://192.168.2.170:9600/',
- // target: 'http://192.168.2.169:9600/',
- changeOrigin: true
- }
- }
- },
- transpileDependencies: ['color-string'] // 此段为增加配置选项
- }
|