操作步骤
.babelrc
webpack.config.js
babel-loader和babel-core版本不对应所产生的,
babel-loader 8.x对应babel-core 7.x
babel-loader 7.x对应babel-core 6.x
所以下载对应的版本就是了,下面是安装babel-core 7.x的方法
npm install -D @babel/core
mldule去掉
module.exports = {
entry: './src/index.js',
output: {
path: __dirname,
filename: './release/bundle.js'
},
// module: {
// rules: [{
// test: /\.js?$/,
// exclude: /(node_modules)/,
// loader: 'babel-loader'
// }]
// },
mode: "development"
}
命令行运行 npm run example
,浏览器访问 http://localhost:8880/example/test.html
一、.babelrc在git中是个隐藏文件
二、运行
1、npm install http-server -g
2、npm run example
readme包含内容
http-server -p 8080 webpack启动端口
module.exports = {
entry: './src/index.js',
output: {
path:__dirname,
filename: './release/bundle.js'
},
module: {
rules: [{
test: /\.js?$/,
exclude: /(node_modules)/,
loader: 'babel-loader'
}]
}
}
{
"presets" : ["es2015","latest"],
"plugins" : []
}