Advertisement
gunnim

Untitled

Feb 23rd, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var path    = require('path');
  2. var webpack = require('webpack');
  3.  
  4. var settings = {
  5.     devtool: 'eval-source-map',
  6.     watch: true,
  7.     entry: {
  8.         app: 'app',
  9.     },
  10.     output: {
  11.         path: path.join(__dirname, '../Umbraco.Site/Scripts'),
  12.         filename: '[name].js'
  13.     },
  14.     module: {
  15.         rules: [
  16.               {
  17.                 test: /\.jsx?$/,
  18.                 exclude: /node_modules/,
  19.                 loader: 'babel-loader',
  20.                 options: {
  21.                     presets: [
  22.                         ['env', { 'modules': false }]
  23.                     ]
  24.                 },
  25.               }
  26.         ]
  27.     },
  28.     plugins: [
  29.     ],
  30.     resolve: {
  31.         modules: [
  32.             path.resolve(__dirname + '/js'),
  33.             'node_modules',
  34.         ],
  35.         extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js", '.jsx'],
  36.         alias: {
  37.         }
  38.     }
  39. };
  40.  
  41. module.exports = function(env) {
  42.  
  43.     if (env && env.prod) {
  44.         settings = Object.assign(settings, {
  45.             devtool: '',
  46.             output: {
  47.                 path: path.join(__dirname, '../Umbraco.Site/scripts'),
  48.                 filename: '[name].min.js'
  49.             },
  50.             plugins: [
  51.                 new webpack.DefinePlugin({
  52.                     'process.env': {
  53.                         // This has effect on the react lib size
  54.                         'NODE_ENV': JSON.stringify('production'),
  55.                     }
  56.                 }),
  57.                 new webpack.optimize.UglifyJsPlugin({})
  58.             ]
  59.         });
  60.     }
  61.  
  62.     return settings;
  63. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement