Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2.  
  3. const webpack = require('webpack');
  4.  
  5. const NODE_ENV = 'development';
  6. // const NODE_ENV = 'production';
  7.  
  8. module.exports = {
  9.     context: __dirname + '/frontend',
  10.     entry: {
  11.         home: './home',
  12.         about: './about',
  13.         welcome: './welcome'
  14.     },
  15.     output: {
  16.         path: __dirname + '/public',
  17.         filename: '[name].js',
  18.         library: '[name]'
  19.     },
  20.  
  21.     devtool: 'source-map',
  22.  
  23.     watch: NODE_ENV == 'development',
  24.     watchOptions: {
  25.         aggregateTimeout: 300,
  26.     },
  27.  
  28.     module: {
  29.         loaders: [
  30.             {
  31.                 loader: "babel-loader?optional[]=runtime",
  32.  
  33.                 // Only run `.js` and `.jsx` files through Babel
  34.                 test: /\.js?$/,
  35.  
  36.                 // Options to configure babel with
  37.                 query: {
  38.                     plugins: ['transform-runtime'],
  39.                     presets: ['es2015'],
  40.                 }
  41.             },
  42.         ]
  43.     },
  44.  
  45.     plugins: [
  46.         new webpack.DefinePlugin({
  47.             NODE_ENV: JSON.stringify(NODE_ENV)
  48.         }),
  49.         new webpack.optimize.CommonsChunkPlugin({
  50.             name: 'common'
  51.         })
  52.     ]
  53. }
  54.  
  55. // PROD
  56.  
  57. if (NODE_ENV == 'production') {
  58.     module.exports.plugins.push(
  59.         new webpack.optimize.UglifyJsPlugin({
  60.             compress: {
  61.                 warnings: false,
  62.                 drop_console: true,
  63.                 unsafe: true
  64.             }
  65.         })
  66.     );
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement