javascript Webpack和Babel配置(Traversy)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Webpack和Babel配置(Traversy)相关的知识,希望对你有一定的参考价值。
{
"name": "babel_webpack_starter",
"version": "1.0.0",
"description": "Starter pack for compiling ES6+ apps to ES5",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack",
"start": "webpack-dev-server --output-public-path=/build/",
"json:server": "json-server --watch api/db.json"
},
"author": "Brad Traversy",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-0": "^6.24.1",
"webpack": "^3.8.1",
"webpack-dev-server": "^2.9.4"
},
"dependencies": {
"json-server": "^0.14.0"
}
}
const path = require('path');
module.exports = {
entry: {
app: [
'babel-polyfill',
'./src/app.js',
],
},
output: {
path: path.resolve(__dirname, 'build'),
filename: 'app.bundle.js',
},
module: {
loaders: [{
test: /\.js?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['env', 'stage-0']
}
}]
}
}
以上是关于javascript Webpack和Babel配置(Traversy)的主要内容,如果未能解决你的问题,请参考以下文章
webpack处理javascript兼容性--Babel
webpack处理javascript兼容性--Babel
Webpack使用教程五(Babel)
webpack,Babel,babel-loader的关系
(15/24) 为webpack增加babel支持
React Native - 为啥我需要 babel 或 webpack?