NetManage/vue.config.js

155 lines
4.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//const HtmlWebpackPlugin = require('html-webpack-plugin')
//const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin')
const path = require("path");
function resolve(dir) {
return path.join(__dirname, dir);
}
const CompressionWebpackPlugin = require('compression-webpack-plugin');
module.exports = {
configureWebpack: {
optimization: {
minimizer: [
new CompressionWebpackPlugin({
test: /\.(js|css|json|ico|svg|png|html|woff|ttf)$/, // 匹配文件名
algorithm: 'gzip', // 使用gzip压缩
//minRatio: 1, // 压缩率小于0.8才会压缩
threshold: 10, // 对超过5k的数据压缩
deleteOriginalAssets: true // 删除源文件
})
]
}
},
// lintOnSave: false,
// productionSourceMap: false,
// chainWebpack: config => {
// // 打包所有文件内嵌到html里面
// //把图片转成base64 limit:1e5 => 100000 kb ,小于这个大小都会转成base64,大于就会用链接引用图片
// config.module
// .rule('images')
// .use('url-loader')
// .loader('url-loader')
// .tap(options => Object.assign(options, {
// esModule: false,
// limit: 1e5
// }));
// //把字体图标相关文件转成base64
// config.module.rule('fonts').use('url-loader')
// .loader('url-loader')
// .tap(options => Object.assign(options, {
// limit: 1e5
// }));
// //把svg转成base64
// //const svgRule = config.module.rule('svg');
// //svgRule.uses.clear();
// config.module.rule('svg').
// use('url-loader')
// .loader('url-loader')
// .tap(options => ({
// esModule: false,
// limit: 1e5
// }));
// config.plugin('inline-source').use(require('html-webpack-inline-source-plugin'));
// config.plugin('html').tap(args => {
// args[0].inlineSource = '(.css|.js$)';
// return args;
// });
// }
//打入一个文件
// lintOnSave: false,
// productionSourceMap: false,
// publicPath: '', //使用相对路径
// indexPath: 'index.html',
// outputDir: 'dist',
// // assetsDir: 'static',
// productionSourceMap: false,
// chainWebpack: config => {
// config.plugin('preload').tap(args => {
// args[0].fileBlacklist.push(/\.css/, /\.js/);
// return args;
// })
// config.plugin('inline-source')
// .use(require('html-webpack-inline-source-plugin'))
// config.plugin("html").tap(args => {
// args[0].chunksSortMode = "none";
// args[0].inlineSource = '(\.css|\.js$)';
// return args;
// });
// config.resolve.alias //添加别名
// .set('@', resolve('src'))
// .set('@assets', resolve('src/assets'))
// .set('@components', resolve('src/components'));
// }
//打入一个文件另一个说法
// configureWebpack: {
// plugins: [
// new HtmlWebpackPlugin({
// title: 'JSON和PHP Array 互转',
// template: 'public/index.html',
// templateParameters: {
// BASE_URL: `/`
// },
// inlineSource: '.(js|css|scss|less)$' // embed all javascript and css inline
// }),
// new HtmlWebpackInlineSourcePlugin()
// ]
// },
/*分开打包*/
//打包不生成map文件
productionSourceMap: false,
//publicPath: process.env.NODE_ENV === "production" ? "/safeControl/" : "/",
// publicPath: process.env.NODE_ENV === "production" ? "http://127.0.0.1/dist" : "",
publicPath: process.env.NODE_ENV === "production" ? "" : "",
css: {
loaderOptions: {
less: {
javascriptEnabled: true
}
}
},
//关闭lint监测
lintOnSave: false,
//开发服务器配置
devServer: {
proxy: {
"/dist/img": {
target: 'http://localhost:8080/img',
//changeOrigin: true, // 是否改变域名
//ws: true,
pathRewrite: {
// 路径重写
"^/dist/img": "" // 这个意思就是以api开头的定向到哪里, 如果你的后边还有路径的话, 会自动拼接上
}
},
"/dist/video": {
target: 'http://localhost:8080/video',
//changeOrigin: true, // 是否改变域名
//ws: true,
pathRewrite: {
// 路径重写
"^/dist/video": "" // 这个意思就是以api开头的定向到哪里, 如果你的后边还有路径的话, 会自动拼接上
}
}
}
}
};