1 Star 0 Fork 18

flclover / mall-cook

forked from 刘宏伟 / mall-cook 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
vue.config.js 2.39 KB
一键复制 编辑 原始数据 按行查看 历史
lanshan 提交于 2021-11-09 09:58 . feat:完善H5商城流程
/*
* @Description: What's this for
* @Autor: WangYuan
* @Date: 2021-05-19 10:53:33
* @LastEditors: WangYuan
* @LastEditTime: 2021-11-05 16:56:06
*/
const path = require('path')
const sftpUploader = require('sftp-uploader')
const productionGzipExtensions = ['js', 'css']
const CompressionWebpackPlugin = require('compression-webpack-plugin')
function resolve (dir) {
return path.join(__dirname, dir)
}
let envConfig = {}
if (process.env.TYPE == 'admin') {
console.log('admin 环境')
envConfig = {
outputDir: 'dist/admin',
pages: {
index: {
entry: 'src/main.js',
template: 'public/index.html',
filename: 'index.html',
chunks: ['chunk-vendors', 'chunk-common', 'index']
}
}
}
} else {
console.log('h5环境')
envConfig = {
outputDir: 'dist/h5',
pages: {
h5: {
entry: 'h5/main.js',
template: 'public/index.html',
filename: 'index.html',
chunks: ['chunk-vendors', 'chunk-common', 'h5']
}
}
}
}
module.exports = {
publicPath: './',
...envConfig,
configureWebpack: config => {
// CDN 加载依赖
config.externals = {
'element-ui': 'ELEMENT',
vue: 'Vue',
vant: 'Vant',
moment: 'moment'
}
// gzip 压缩
console.log('GZIP');
console.log(process.env.GZIP);
if (process.env.GZIP == 'true') {
console.log('执行GZIP')
config.plugins.push(
new CompressionWebpackPlugin({
algorithm: 'gzip',
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 10240,
minRatio: 0.8
})
)
}
},
chainWebpack: config => {
// 别名配置
config.resolve.alias
.set('components', resolve('src/components'))
.set('views', resolve('src/views'))
.set('@', resolve('src'))
// 定义全局scss变量
const oneOfsMap = config.module.rule('scss').oneOfs.store
oneOfsMap.forEach(item => {
item
.use('sass-resources-loader')
.loader('sass-resources-loader')
.options({
// 公用scss
resources: './src/scss/index.scss'
})
.end()
})
config.module
.rule('scss')
.oneOf('vue')
.use('px2rem-loader')
.loader('px2rem-loader')
.before('postcss-loader') // this makes it work.
.options({ remUnit: 37.5, remPrecision: 8 })
.end()
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/flclover/mall-cook.git
git@gitee.com:flclover/mall-cook.git
flclover
mall-cook
mall-cook
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891