Files
wechatpay-enterprise-web/vue.config.js
jefferyzhao b9bdc8598b first commit
2025-07-31 17:44:12 +08:00

74 lines
2.2 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 CompressionPlugin = require('compression-webpack-plugin');
const pxtovw = require('postcss-px-to-viewport');
const isProduction = process.env.NODE_ENV === 'production';
module.exports = {
outputDir: 'm',
publicPath: isProduction ? '/m/' : '/',
productionSourceMap: false,
css: {
loaderOptions: {
less: {
// 若 less-loader 版本小于 6.0,请移除 lessOptions 这一级,直接配置选项。
lessOptions: {
modifyVars: {
// 直接覆盖变量
'text-color': '#111',
'border-color': '#eee',
// 或者可以通过 less 文件覆盖(文件路径为绝对路径)
hack: `true; @import "~@/assets/styles/vant-reset.less";`,
},
},
},
sass: {
prependData: `@import "~@/assets/styles/variables.scss";`,
},
postcss: {
plugins: [
new pxtovw({
unitToConvert: 'px', //需要转换的单位,默认为"px"
viewportWidth: 375, //设计稿的视口宽度
unitPrecision: 5, //单位转换后保留的小数位数
propList: ['*'], //要进行转换的属性列表,*表示匹配所有,!表示不转换
viewportUnit: 'vw', //转换后的视口单位
fontViewportUnit: 'vw', //转换后字体使用的视口单位
selectorBlackList: [], //不进行转换的css选择器继续使用原有单位
minPixelValue: 1, //设置最小的转换数值
mediaQuery: false, //设置媒体查询里的单位是否需要转换单位
replace: true, //是否直接更换属性值,而不添加备用属性
exclude: [/node_modules/], //忽略某些文件夹下的文件
}),
],
},
},
},
devServer: {
proxy: '',
// proxy: {
// '/api': {
// target: 'http://172.16.6.6:3005', // 后端服务器地址
// changeOrigin: true,
// pathRewrite: {
// '^/api': ''
// },
// onProxyRes(proxyRes, req, res) {
// // 在代理响应中添加 CORS 头信息
// proxyRes.headers['Access-Control-Allow-Origin'] = '*';
// }
// }
// }
},
configureWebpack: config => {
if (isProduction) {
config.plugins.push(
new CompressionPlugin({
test: /\.(js|css)$/,
algorithm: 'gzip',
deleteOriginalAssets: false,
}),
);
console.log(config);
}
},
};