Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. 1. First Install your dependencies:
  2.  
  3. ```bash
  4. npm install webpack@beta babel-loader babel-core babel-preset-es2015-native-modules --save-dev
  5. ```
  6.  
  7. 2. Then, Create a `webpack.config.js` file:
  8.  
  9. ```js
  10. const webpack = require('webpack');
  11. const nodeEnv = process.env.NODE_ENV || 'production';
  12.  
  13. module.exports = {
  14. devtool: 'source-map',
  15. entry: {
  16. filename: './app.js'
  17. },
  18. output: {
  19. filename: '_build/bundle.js'
  20. },
  21. module: {
  22. loaders: [
  23. {
  24. test: /\.js$/,
  25. exclude: /node_modules/,
  26. loader: 'babel-loader',
  27. query: {
  28. presets: ['es2015-native-modules']
  29. }
  30. }
  31. ]
  32. },
  33. plugins: [
  34. new webpack.optimize.UglifyJsPlugin({
  35. compress: {
  36. warnings: false
  37. },
  38. output: {
  39. comments: false
  40. },
  41. sourceMap: true
  42. }),
  43. new webpack.DefinePlugin({
  44. 'process.env': { NODE_ENV: JSON.stringify(nodeEnv) }
  45. })
  46. ]
  47. };
  48. ```
  49.  
  50. 3. Setup the build npm script in `package.json`:
  51.  
  52. ```json
  53. "build": "webpack --progress --watch"
  54. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement