本文主要是介绍vue 配置babel,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
首先install babel
cnpm install --save-dev babel-loader babel-core babel-preset-env babel-plugin-transform-runtime babel-plugin-istanbul babel-polyfill babel-preset-stage-2 babel-register
webpack module配置
module: {rules: [{test: /\.vue$/, loader: 'vue-loader', options: {loaders: {scss: 'vue-style-loader!css-loader!sass-loader' // <style lang="scss"> }}}, {test: /\.js$/, exclude: /(node_modules|bower_components)/, loader: 'babel-loader' }] }
为了兼容ie 入口处加入 babel-polyfil
entry: {app: ['babel-polyfill', './src/main.js'] },
然后在根目录新建.babelrc文件 加入配置项
{"presets": [["env", { "modules": false }], "stage-2" ], "plugins": ["transform-runtime"], "comments": false, "env": {"test": {"presets": ["env", "stage-2"], "plugins": [ "istanbul" ]}} }
这篇关于vue 配置babel的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!