改成ES5打包
This commit is contained in:
@ -1,46 +1,52 @@
|
||||
const {defineConfig} = require('@vue/cli-service')
|
||||
const postcssPxToViewport = require('postcss-px-to-viewport')
|
||||
const path = require('path') // 需要引入 path 模块
|
||||
const path = require('path')
|
||||
|
||||
module.exports = defineConfig({
|
||||
publicPath: './',
|
||||
transpileDependencies: false,
|
||||
transpileDependencies: false, // 我们自己管,不让 CLI 插手
|
||||
lintOnSave: false,
|
||||
devServer: {
|
||||
client: {
|
||||
overlay: false,
|
||||
},
|
||||
},
|
||||
configureWebpack: (config) => {
|
||||
//调试JS
|
||||
devServer: {client: {overlay: false}},
|
||||
|
||||
configureWebpack(config) {
|
||||
// 调试
|
||||
config.devtool = 'source-map'
|
||||
config.resolve = {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, 'src'),
|
||||
// 别名
|
||||
config.resolve.alias['@'] = path.resolve(__dirname, 'src')
|
||||
|
||||
/* 1. 追加 ini 规则 */
|
||||
config.module.rules.push({
|
||||
test: /\.ini$/,
|
||||
use: 'raw-loader',
|
||||
})
|
||||
|
||||
/* 2. 追加 ES5 规则(只转 src,不转 node_modules) */
|
||||
config.module.rules.push({
|
||||
test: /\.js$/,
|
||||
include: path.resolve(__dirname, 'src'),
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
presets: [
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
targets: {ie: '11'}, // 强制 ES5
|
||||
corejs: 3,
|
||||
useBuiltIns: 'entry',
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
// 添加 .ini 文件处理规则
|
||||
if (config.module && config.module.rules) {
|
||||
config.module.rules.push({
|
||||
test: /\.ini$/,
|
||||
use: 'raw-loader'
|
||||
})
|
||||
} else {
|
||||
config.module = {
|
||||
rules: [
|
||||
{
|
||||
test: /\.ini$/,
|
||||
use: 'raw-loader'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
css: {
|
||||
/* 你的 px-to-viewport 配置不动 */
|
||||
loaderOptions: {
|
||||
postcss: {
|
||||
postcssOptions: {
|
||||
// 增加这一层 postcssOptions
|
||||
plugins: [
|
||||
postcssPxToViewport({
|
||||
unitToConvert: 'px',
|
||||
@ -53,7 +59,7 @@ module.exports = defineConfig({
|
||||
minPixelValue: 1,
|
||||
mediaQuery: false,
|
||||
replace: true,
|
||||
exclude: /(\/|\\)(node_modules)(\/|\\)/,
|
||||
exclude: /node_modules/,
|
||||
include: [],
|
||||
landscape: false,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user