Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var glob = require('glob'),
  2.     ngAnnotate = require('ng-annotate-webpack-plugin'),
  3.     ExtractTextPlugin = require('extract-text-webpack-plugin'),
  4.     webpack = require('webpack');
  5.  
  6. const prod = process.argv.indexOf('-p') !== -1;
  7.  
  8. var plugins = [
  9.     new ngAnnotate({
  10.         add: true,
  11.     }),
  12.     new ExtractTextPlugin('bundle.css'),
  13.     new webpack.optimize.CommonsChunkPlugin({
  14.         name: 'profile',
  15.         children: true,
  16.         minChunks: 2,
  17.         async: true
  18.     }),
  19. ];
  20.  
  21. if (prod) {
  22.     plugins.push(
  23.         new webpack.NoEmitOnErrorsPlugin(),
  24.         new webpack.optimize.UglifyJsPlugin({
  25.             beautify: false,
  26.             comments: false,
  27.             compress: {
  28.                 sequences: true,
  29.                 booleans: true,
  30.                 loops: true,
  31.                 unused: true,
  32.                 warnings: false,
  33.                 drop_console: true,
  34.                 unsafe: true
  35.             }
  36.         })
  37.     );
  38. }
  39.  
  40. module.exports = {
  41.     entry: {
  42.         bundle: __dirname + '/application/application.js',
  43.         profile: __dirname + '/application/modules/profile.module.js'
  44.     },
  45.     output: {
  46.         path: __dirname + '/build',
  47.         filename: '[name].js'
  48.     },
  49.     plugins: plugins,
  50.     resolve: {
  51.         alias: {
  52.             moment: __dirname + '/node_modules/moment/min/moment'
  53.         },
  54.     },
  55.     module: {
  56.         loaders: [
  57.             {
  58.                 test: /\.js$/,
  59.                 loader: 'babel-loader',
  60.                 query: {
  61.                     presets: ['babel-preset-es2015'].map(require.resolve)
  62.                 },
  63.                 exclude: /(node_modules|bower_components)/
  64.             },
  65.             {
  66.                 test: /\.(png|woff|woff2|eot|ttf|svg|gif|jpg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
  67.                 loader: 'url-loader',
  68.                 options: {
  69.                     limit: 1
  70.                 }
  71.             },
  72.             {
  73.                 test: /\.css$/,
  74.                 loader: ExtractTextPlugin.extract({
  75.                     fallback: 'style-loader',
  76.                     use: 'css-loader'
  77.                 })
  78.             }
  79.         ]
  80.     },
  81.     node: {
  82.         fs: 'empty'
  83.     },
  84.     devServer: {
  85.         historyApiFallback: true
  86.     }
  87. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement