Advertisement
Guest User

Untitled

a guest
Jul 21st, 2020
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const path = require('path')
  2. const { CleanWebpackPlugin: CleanPlugin } = require('clean-webpack-plugin')
  3. const LoadablePlugin = require('@loadable/webpack-plugin')
  4.  
  5. const NODE_ENV = process.env.NODE_ENV ? process.env.NODE_ENV : 'development'
  6.  
  7. function isProduction() {
  8.     return NODE_ENV === 'production'
  9. }
  10.  
  11. const cssLoader = {
  12.     loader: 'css-loader',
  13.     options: {
  14.         modules: {
  15.             mode: 'local',
  16.             localIdentName: isProduction() ? '[contenthash:8]' : '[name]-[contenthash:8]'
  17.         }
  18.     }
  19. }
  20.  
  21. module.exports = {
  22.     entry: {
  23.         app: path.resolve(__dirname, 'src', 'index.ts')
  24.     },
  25.     output: {
  26.         filename:      '[name].js',
  27.         chunkFilename: '[chunkhash].js',
  28.         path:          path.resolve(__dirname, '../', 'dist', 'client'),
  29.         publicPath:    '/dist/'
  30.     },
  31.     devtools: false,
  32.     target: 'node',
  33.     resolve: {
  34.         extensions: [
  35.             '.styl',
  36.             '.tsx',
  37.             '.ts',
  38.             '.jsx',
  39.             '.js'
  40.         ]
  41.     },
  42.     module: {
  43.         rules: [
  44.             {
  45.                 test: /\.tsx?$/,
  46.                 exclude: /node_modules/,
  47.                 use: [
  48.                     'babel-loader',
  49.                     'ts-loader'
  50.                 ]
  51.             },
  52.             {
  53.                 test: /\.jsx?$/,
  54.                 exclude: /node_modules/,
  55.                 use: [
  56.                     'babel-loader'
  57.                 ]
  58.             },
  59.             {
  60.                 test: /\.css$/,
  61.                 use: [
  62.                     'null-loader',
  63.                     cssLoader
  64.                 ]
  65.             },
  66.             {
  67.                 test: /\.styl$/,
  68.                 use: [
  69.                     'null-loader',
  70.                     cssLoader,
  71.                     'stylus-loader'
  72.                 ]
  73.             }
  74.         ]
  75.     },
  76.     plugins: [
  77.         new CleanPlugin(),
  78.         new LoadablePlugin()
  79.     ],
  80.     stats: {
  81.         children: false
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement