beginner, excuse me.
1. Question:
webpack + vue-cli project, using babel to escape es6, in which I have a js written in the old-fashioned way, such as this:
delete obj;
webpack will report an error in strict mode, so modify the babel configuration file .babelrc to ignore the js file with ignore, but it is not valid
2. Code:
.babelrc
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"],
"env": {
"test": {
"presets": ["env", "stage-2"],
"plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"]
}
},
"ignore":[
"./src/assets/alerter.js"
]
}
I added the last ignore, myself and everything else is the original
. 3. Error report: the result after
npm run dev is still prompted to escape
4. Try the
plug-in to remove strict-mode
first: npm install babel-plugin-transform-remove-strict-mode-- save-dev
and then: .babelrc
"plugins": [
"transform-remove-strict-mode"
]
as follows:
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime","transform-remove-strict-mode"],
"env": {
"test": {
"presets": ["env", "stage-2"],
"plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"]
}
},
"ignore":[
"./src/assets/qksheet/alerter.js"
]
}
still report an error
Note: the design area of the old code is too large to consider changes until it is a last resort. It used to run normally without the webpack tool.
Thank you!