Skip to content

Instantly share code, notes, and snippets.

@IrenaYuan
Created March 15, 2018 07:24
Show Gist options
  • Save IrenaYuan/22bb40809696ce96cadd6ac71c19c7c9 to your computer and use it in GitHub Desktop.
Save IrenaYuan/22bb40809696ce96cadd6ac71c19c7c9 to your computer and use it in GitHub Desktop.
Note for webpack3 with babel, react...setting
module.exports = {
//...
module: {
/* version 1
* use loaders
*/
loaders:[
{
test: /\.js[x]?$/,
exclude: /node_modules/,
loader: 'babel-loader?presets[]=es2015&presets[]=react',
},
],
/* version 2
* loaders > rules
*/
rules: [{
test: /\.js[x]?$/,
exclude: /node_modules/,
loader: 'babel-loader?presets[]=es2015&presets[]=react'
}],
/* version 3
* following webpack docs `babel-loader`
* note: options > presents 一般都是寫在.babelrc內
* 但這樣寫可以動
*/
rules: [{
test: /\.js[x]?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['es2015', 'react']
}
}
}]
}
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment