In webpack developed, will encounter a big push issues, especially babel6 upgrade to babel7, a big push to keep the new plug-in, and for the installation of babel function is in webpack development, vue new features that can be used for ES6:
E.g. ES6 in object-oriented programming mode:
class Person{ static info = { name: "zs", age: 20} } console.log(Person.info)
For this, js is not, but in webpack, the default can only deal with part of the new syntax for ES6, ES6 some advanced grammar or syntax ES7, webpack is not treated; this time you need help with a third party loader to webpack help deal with these advanced grammar, when a third-party loader to a lower level syntax into the syntax, the result will go to the webpack packed into bundle.js.
Only you can help us by Babel will be converted to low-level syntax syntax:
1. Install the plug-look
"devDependencies": { "@babel/core": "^7.4.5", "@babel/plugin-proposal-class-properties": "^7.4.4", "@babel/plugin-proposal-object-rest-spread": "^7.4.4", "@babel/plugin-transform-runtime": "^7.4.4", "@babel/preset-env": "^7.4.5", "@babel/preset-react": "^7.0.0", "@babel/runtime": "^7.4.5", "babel-loader": "^8.0.6" }
2. Open webpack profile in the rules array of module node, add a new matching rules:
{test"/\.js$/, use :"babel-loader", exclude:/node_modules/}
{ "presets": ["@babel/preset-env", "@babel/preset-react"], "plugins": ["@babel/plugin-transform-runtime", "@babel/plugin-proposal-object-rest-spread", "@babel/plugin-proposal-class-properties"] }