Veikedo

Untitled

Oct 5th, 2017
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const typescript = require('@webpack-blocks/typescript');
  2. const {addPlugins, createConfig, customConfig, entryPoint, defineConstants, env, setOutput, sourceMaps} =
  3.     require('@webpack-blocks/webpack2');
  4. const webpack = require('webpack');
  5. const LiveReloadPlugin = require('webpack-livereload-plugin');
  6. const WebpackBuildNotifierPlugin = require('webpack-build-notifier');
  7. const NODE_ENV = process.env.NODE_ENV = process.env.NODE_ENV || 'development';
  8. const postcss = require('@webpack-blocks/postcss');
  9. const sass = require('@webpack-blocks/sass');
  10. const autoprefixer = require('autoprefixer');
  11. const extractText = require('@webpack-blocks/extract-text2');
  12. const tslint = require('@webpack-blocks/tslint');
  13.  
  14. module.exports = createConfig([
  15.     entryPoint({
  16.         'customer-support': './ClientApp/index.tsx',
  17.         'my-posts-chat': './ClientApp/Routes/MyPosts/index.tsx',
  18.         // 'chat': './ClientApp/Components/Chat/Chat.tsx',
  19.     }),
  20.     setOutput({
  21.         path: __dirname + '/wwwroot',
  22.         filename: '[name].bundle.js',
  23.         sourceMapFilename: '[name].map',
  24.         chunkFilename: '[id].chunk.js'
  25.     }),
  26.     defineConstants({
  27.         'process.env.NODE_ENV': `${NODE_ENV}`,
  28.         'DEBUG': NODE_ENV === 'development',
  29.         'PRODUCTION': NODE_ENV === 'production'
  30.     }),
  31.     typescript(),
  32.     tslint(),
  33.     sass(),
  34.     postcss([
  35.         autoprefixer({browsers: ['last 4 versions']})
  36.     ]),
  37.     customConfig({
  38.         externals: {
  39.             'moment': 'moment',
  40.         }
  41.     }),
  42.     addPlugins([
  43.         new webpack.optimize.CommonsChunkPlugin({
  44.             name: 'vendor',
  45.             minChunks: function (module) {
  46.                 const context = module.context;
  47.                 return context && context.indexOf('node_modules') >= 0;
  48.             },
  49.         }),
  50.     ]),
  51.     env('development', [
  52.         // will only enable source maps if `NODE_ENV === 'development'`
  53.         sourceMaps('cheap-module-eval-source-map'),
  54.         addPlugins([
  55.             new LiveReloadPlugin({}),
  56.             new WebpackBuildNotifierPlugin({
  57.                 title: 'Billy3 Frontend Build',
  58.                 suppressSuccess: true
  59.             })
  60.         ])
  61.     ]),
  62.     env('production', [
  63.         sourceMaps('source-map'),
  64.         extractText('[name].css', 'text/x-sass'),
  65.         addPlugins([
  66.             new webpack.optimize.UglifyJsPlugin({
  67.                 beautify: false,
  68.                 sourceMap: true,
  69.                 comments: false,
  70.                 mangle: {
  71.                     screw_ie8: true,
  72.                     keep_fnames: true
  73.                 },
  74.                 compress: {
  75.                     screw_ie8: true,
  76.                     warnings: false
  77.                 },
  78.             }),
  79.         ])
  80.     ])
  81. ]);
Advertisement
Add Comment
Please, Sign In to add comment