Advertisement
Guest User

Untitled

a guest
Jul 6th, 2018
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const path = require('path');
  2. const MiniCssExtractPlugin = require("mini-css-extract-plugin")
  3. const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
  4. const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
  5.  
  6. // module export
  7.  
  8. module.exports = (env) => {
  9.     return {
  10.         entry: './src/app.js',
  11.         output: {
  12.             path: path.join(__dirname, 'public', 'dist'),
  13.             filename: 'bundle.js'
  14.         },
  15.         optimization: {
  16.             minimizer: [
  17.                 new UglifyJsPlugin({
  18.                     cache: true,
  19.                     parallel: true,
  20.                     sourceMap: true
  21.                 }),
  22.                 new OptimizeCSSAssetsPlugin({})
  23.             ]
  24.         },
  25.         module: {
  26.             rules: [{
  27.                 loader: 'babel-loader',
  28.                 test: /\.js$/,
  29.                 exclude: /node_modules/
  30.             }, {
  31.                 test: /\.s?css$/,
  32.                 use: [
  33.                     MiniCssExtractPlugin.loader,
  34.                     {
  35.                         loader: 'css-loader'
  36.                     },
  37.                     {
  38.                         loader: 'sass-loader'
  39.                     }
  40.                 ]
  41.             }]
  42.         },
  43.         plugins: [
  44.             new MiniCssExtractPlugin({
  45.               filename: "[name].css",
  46.               chunkFilename: "[id].css"
  47.             })
  48.           ],
  49.         devtool: env ? 'source-map' : 'cheap-moduule-eval-source-map',
  50.         devServer: {
  51.             contentBase: path.join(__dirname, 'public'),
  52.             historyApiFallback: true,
  53.             publicPath: '/dist/'
  54.         },
  55.         mode: 'development'
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement