Advertisement
Guest User

Untitled

a guest
Sep 21st, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const webpack = require("webpack");
  2. const AsyncChunkNames = require('webpack-async-chunk-names-plugin');
  3. const CleanWebpackPlugin = require('clean-webpack-plugin');
  4.  
  5. const autoprefixer = require('autoprefixer');
  6.  
  7. const path = require('path');
  8. const buildPath = path.join(__dirname, 'dist');
  9.  
  10. const appPath = path.join(__dirname, 'src');
  11.  
  12. module.exports = {
  13.     entry: appPath,
  14.   optimization: {minimize: process.env.NODE_ENV === 'production'},
  15.   resolve: {
  16.     extensions: ['.js', '.jsx'],
  17.     modules: ['app', 'node_modules']
  18.   },
  19.   output: {
  20.     filename: 'calculator.js',
  21.     chunkFilename: '[chunkhash].js'
  22.   },
  23.  
  24.     plugins: [
  25.       new AsyncChunkNames(),
  26.       new webpack.NamedModulesPlugin(),
  27.       new webpack.DefinePlugin({
  28.         'process.env.NODE_ENV': JSON.stringify('production')
  29.       }),
  30.       new webpack.HotModuleReplacementPlugin(),
  31.       new CleanWebpackPlugin(buildPath, {
  32.         root: process.cwd()
  33.       })
  34.     ],
  35.     module: {
  36.       rules: [
  37.         {
  38.           test: /\.(js|jsx)$/,
  39.           exclude: /node_modules/,
  40.           loader: 'babel-loader',
  41.           include: appPath
  42.         },
  43.         {
  44.           test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
  45.           use: [
  46.             {
  47.               loader: 'file-loader'
  48.             }
  49.           ],
  50.           include: appPath
  51.         },
  52.         {
  53.           test: /\.(png|jpg)$/,
  54.           use: [
  55.             {
  56.               loader: 'file-loader'
  57.             }
  58.           ]
  59.         }
  60.       ]
  61.     }
  62. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement