const path = require('path') const webpack = require('webpack') const CompressionWebpackPlugin = require("compression-webpack-plugin"); function resolve(dir) { return path.join(__dirname, dir) } // vue.config.js module.exports = { pages: { index: { // page 的入口 entry: 'src/main.js', // 模板来源 template: 'public/index.html', // 在 dist/index.html 的输出 filename: 'index.html', // 当使用 title 选项时, // template 中的 title 标签需要是 <%= htmlWebpackPlugin.options.title %> title: '河北省住建处大数据服务系统', // 在这个页面中包含的块,默认情况下会包含 // 提取出来的通用 chunk 和 vendor chunk。 chunks: ['chunk-vendors', 'chunk-common', 'index'] } }, // ...other config configureWebpack: config => { config.performance = { hints: 'warning', //入口起点的最大体积 整数类型(以字节为单位) maxEntrypointSize: 50000000, //生成文件的最大体积 整数类型(以字节为单位 300k) maxAssetSize: 30000000, //只给出 js 文件的性能提示 assetFilter: function (assetFilename) { return assetFilename.endsWith('.js') } } const plugins = []; // 同externals一样,我们只想在生产环境下生成gzip即可 if (process.env.NODE_ENV === 'production') { plugins.push( new CompressionWebpackPlugin({ filename: '[path].gz[query]', // 生成的文件名 algorithm: 'gzip', // 类型 test: new RegExp('\\.(js|css)$'), // 匹配规则 threshold: 10240, // 字节数 只处理比这个大的资源 minRatio: 0.8, // 压缩率 只有比这个小的才会处理 // 是否删除源文件,默认: false deleteOriginalAssets: false }) ) } config.plugins = [ ...config.plugins, ...plugins ] let rules = [{ test: /\.geojson$/, loader: 'json-loader' }] config.module.rules = [ ...config.module.rules, ...rules ] }, // { // // webpack plugins // plugins: [ // // Ignore all locale files of moment.js // new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), // new CompressionWebpackPlugin({ // filename: '[path].gz[query]', // 生成的文件名 // algorithm: 'gzip', // 类型 // test: new RegExp('\\.(js|css)$'), // 匹配规则 // threshold: 10240, // 字节数 只处理比这个大的资源 // minRatio: 0.8 // 压缩率 只有比这个小的才会处理 // }) // ], // module: { // rules: [{ // test: /\.geojson$/, // loader: 'json-loader' // }] // } // }, productionSourceMap: false, //打包不生成js.map文件 chainWebpack: (config) => { config.resolve.alias .set('@$', resolve('src')) .set('@static', resolve('public/static')) }, css: { loaderOptions: { less: { modifyVars: { 'primary-color': '#F05A28', 'border-color-base': '#F05A28', 'heading-color': 'rgba(240, 90, 40, 1)', 'link-color': '#F05A28' }, javascriptEnabled: true }, } }, pluginOptions: { "style-resources-loader": { preProcessor: "less", patterns: [ path.resolve(__dirname, 'src/assets/less/variable.less') ] } }, devServer: { port: 1002, proxy: { '/proxy_oauth/': { target: 'http://121.43.55.7:10086', changeOrigin: true, pathRewrite: { '^/proxy_oauth': '' } }, '/proxy_data/': { target: 'http://121.43.55.7:10087', changeOrigin: true, pathRewrite: { '^/proxy_data': '' } }, // '/proxy_data/': { // target: 'http://192.168.1.61:10087', // changeOrigin: true, // pathRewrite: { // '^/proxy_data': '' // } // }, '/proxy_mark/': { target: 'http://121.43.55.7:10088', changeOrigin: true, pathRewrite: { '^/proxy_mark': '' } }, } } }