Created
June 23, 2017 17:10
-
-
Save evaldosantos/d0816282251bb3fbba7e470bc317dd6e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. First Install your dependencies: | |
```bash | |
npm install webpack@beta babel-loader babel-core babel-preset-es2015-native-modules --save-dev | |
``` | |
2. Then, Create a `webpack.config.js` file: | |
```js | |
const webpack = require('webpack'); | |
const nodeEnv = process.env.NODE_ENV || 'production'; | |
module.exports = { | |
devtool: 'source-map', | |
entry: { | |
filename: './app.js' | |
}, | |
output: { | |
filename: '_build/bundle.js' | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
loader: 'babel-loader', | |
query: { | |
presets: ['es2015-native-modules'] | |
} | |
} | |
] | |
}, | |
plugins: [ | |
new webpack.optimize.UglifyJsPlugin({ | |
compress: { | |
warnings: false | |
}, | |
output: { | |
comments: false | |
}, | |
sourceMap: true | |
}), | |
new webpack.DefinePlugin({ | |
'process.env': { NODE_ENV: JSON.stringify(nodeEnv) } | |
}) | |
] | |
}; | |
``` | |
3. Setup the build npm script in `package.json`: | |
```json | |
"build": "webpack --progress --watch" | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
npm run task-name