You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.6 KiB
64 lines
1.6 KiB
const path = require('path')
|
|
const resolve = file => path.resolve(__dirname, file)
|
|
const pxtorem = require('postcss-pxtorem');
|
|
const webpack = require('webpack') //JQ
|
|
|
|
const isUrl = false;
|
|
let baseURL;
|
|
if (isUrl) {
|
|
//正式站
|
|
baseURL = 'http://api.zhdespi.com';
|
|
} else {
|
|
//测试站
|
|
baseURL = 'http://192.168.1.121:60011';
|
|
}
|
|
|
|
module.exports = {
|
|
publicPath: './', //HBuilder打包出现空白决解方案
|
|
productionSourceMap: false,//是否生成.map文件.map文件的作用是帮助编译后的代码调试,但是我们上线的代码已经调试完成,所以上线时可以不生成.map文件
|
|
//解决跨域
|
|
devServer: {
|
|
//port: 8081,// 端口号
|
|
//open: true, //配置自动启动浏览器
|
|
proxy: {
|
|
//测试站
|
|
'/api': {
|
|
target: baseURL, //对应自己的接口
|
|
changeOrigin: true,
|
|
ws: true,
|
|
pathRewrite: {
|
|
'^/api': ''
|
|
}
|
|
},
|
|
}
|
|
},
|
|
|
|
chainWebpack: config => {
|
|
config.module
|
|
.rule('md-postcss') // 新增规则,规则名自定义
|
|
.test(/mand-mobile.*\.css$/) // 用正则表达式匹配mand-mobile的组件目录下的所有css文件
|
|
.use('css-loader') // css加载器
|
|
.loader('postcss-loader') // css处理器
|
|
.options({ // 这里的内容跟方法一中css.loaderOptions一样
|
|
plugins: [
|
|
pxtorem({
|
|
rootValue: 55,
|
|
minPixelValue: 2,
|
|
propList: ['*'],
|
|
selectorBlackList: []
|
|
})
|
|
]
|
|
});
|
|
},
|
|
//引入JQ
|
|
configureWebpack: {
|
|
plugins: [
|
|
new webpack.ProvidePlugin({
|
|
$: "jquery",
|
|
jQuery: "jquery",
|
|
jquery: "jquery",
|
|
"windows.jQuery": "jquery"
|
|
})
|
|
]
|
|
}
|
|
}
|