123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- const CompressionPlugin = require("compression-webpack-plugin");
- const webpack = require("webpack");
- const BundleAnalyzerPlugin =
- require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
- module.exports = {
- outputDir: process.env.outputDir,
- 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: -10qa
- // },
- // '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: {
- // 开发环境变化可注释 ⬇️⬇️
- "/market/CMK": {
- target: "http://192.168.2.124:9113",
- ws: false,
- changeOrigin: true,
- pathRewrite: {
- "^/market": "",
- },
- },
- "/aps": {
- target: "http://192.168.2.124:7779",
- ws: false,
- changeOrigin: true,
- logLevel:'debug',
- pathRewrite: {
- "^/aps": "",
- },
- },
- "/market/mk": {
- target: "http://192.168.2.124:9113",
- ws: false,
- changeOrigin: true,
- pathRewrite: {
- "^/market": "",
- },
- },
- "/market/techcentergj": {
- target: "http://192.168.2.124:9113",
- ws: false,
- changeOrigin: true,
- pathRewrite: {
- "^/market": "",
- },
- },
- // "/api": {
- // target: "http://43.138.50.94:7777",
- // ws: false,
- // changeOrigin: true,
- // pathRewrite: {
- // "^/api": "",
- // },
- // },
- // 开发环境变化可注释 ⬆️⬆️
- "/": {
- // 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.1.9:9600/spfm',
- // target: 'http://127.0.0.1:9600/',
- // target: 'http://192.168.0.156:9600/',
- // target: 'http://192.168.2.92:9600/',
- // target: 'http://192.168.2.124:9600/',
- // target: "http://124.223.66.248:9600",
- // target: "http://43.138.50.94:9600",
- // target: 'http://192.168.2.44:9600/',
- // target: 'http://192.168.2.124:9600',
- // target: "http://124.223.66.248:9600",
- target: "http://43.138.50.94:9600",
- changeOrigin: true,
- // logLevel:'debug',
- },
- },
- },
- transpileDependencies: ["color-string"], // 此段为增加配置选项
- };
|