【无标题】vue.config.js

‘use strict’
const path = require(‘path’)
const StyleLintPlugin = require(‘stylelint-webpack-plugin’)
const CompressionPlugin = require(‘compression-webpack-plugin’)
// const defaultSettings = require(‘./src/settings.js’)
// const px2rem = require(‘postcss-px2rem’)
// // 配置基本大小
// const postcss = px2rem({
// // 基准大小 baseSize,需要和rem.js中相同
// remUnit: 16,
// })
function resolve(dir) {
return path.join(__dirname, dir)
}

// const name = defaultSettings.title || ‘魔方’ // page title

const port = process.env.port || process.env.npm_config_port || 2000

module.exports = {
publicPath: ‘/’,
outputDir: ‘dist-admin’,
assetsDir: ‘static’,
lintOnSave: process.env.NODE_ENV === ‘development’,
productionSourceMap: false,
devServer: {
port: port,
open: true,
overlay: {
warnings: false,
errors: true,
},
proxy: {
‘/devApi’: {
// target: ‘http://test.vooglam.xmslol.cn’,
target: ‘http://dev.vooglam.xmslol.cn’,
changeOrigin: true,
secure: false,
pathRewrite: {
‘^/devApi’: ‘/’,
},
},
‘/mock’: {
target: ‘http://127.0.0.1:4523/mock/391333’,
changeOrigin: true,
secure: false,
pathRewrite: {
‘^/mock’: ‘/’,
},
},
},
},
css: {
sourceMap: process.env.NODE_ENV === ‘development’, //! 只在本地的开发环境中开启
loaderOptions: {
sass: {
prependData: ‘@import “./src/assets/styles/mixins.scss”;@import “./src/assets/styles/theme.scss”;@import “./src/assets/styles/mj_common_ui.scss”;’,
},
// postcss: {
// plugins: [
// // postcss // 暂时不转rem
// ],
// },
},
},
configureWebpack: (config) => {
//! 本地的开发环境调试
if (process.env.NODE_ENV === ‘development’) {
config.devtool = ‘source-map’
}
},
chainWebpack(config) {
config.resolve.alias.set(‘@’, resolve(‘src’))
// stylelint配置
config.plugin(‘stylelint’).use(StyleLintPlugin, [
{
files: [‘**/*.{html,vue,css,sass,scss}’],
fix: true, // 自动修复
cache: false,
emitError: true,
failOnError: false,
},
])
config.output.filename(‘[name].[hash].js’).end()
config.output.chunkFilename(‘[name].[hash].js’).end()
config.plugin(‘compressionPlugin’)
.use(
new CompressionPlugin({
filename: ‘[path].gz[query]’,
algorithm: ‘gzip’,
test: /.jsKaTeX parse error: Can't use function '\.' in math mode at position 2: |\̲.̲html|.cssKaTeX parse error: Expected 'EOF', got '}' at position 142: … }̲, …/, /hot-update.jsKaTeX parse error: Can't use function '\.' in math mode at position 12: /, /runtime\̲.̲.*\.js/],
include: ‘initial’,
},
])
},
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值