Advertisement
Guest User

Untitled

a guest
Apr 19th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const path = require('path');
  2. const glob = require('glob');
  3. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  4. const TerserPlugin = require('terser-webpack-plugin');
  5. const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
  6. const CopyWebpackPlugin = require('copy-webpack-plugin');
  7.  
  8. module.exports = (env, options) => {
  9.   const devMode = options.mode !== 'production';
  10.  
  11.   return {
  12.     optimization: {
  13.       minimizer: [
  14.         new TerserPlugin({ cache: true, parallel: true, sourceMap: devMode }),
  15.         new OptimizeCSSAssetsPlugin({})
  16.       ]
  17.     },
  18.     entry: {
  19.       'app': glob.sync('./vendor/**/*.js').concat(['./js/app.js'])
  20.     },
  21.     output: {
  22.       filename: '[name].js',
  23.       path: path.resolve(__dirname, '../priv/static/js'),
  24.       publicPath: '/js/'
  25.     },
  26.     devtool: devMode ? 'source-map' : undefined,
  27.     module: {
  28.       rules: [
  29.         {
  30.           test: /\.svelte$/,
  31.           use: {
  32.             loader: 'svelte-loader',
  33.             options: {
  34.               emitCss: true,
  35.               hotReload: true
  36.             }
  37.           }
  38.         },
  39.         {
  40.           test: /\.js$/,
  41.           exclude: /node_modules/,
  42.           use: {
  43.             loader: 'babel-loader'
  44.           }
  45.         },
  46.         {
  47.           test: /\.css$/,
  48.           use: [
  49.             MiniCssExtractPlugin.loader,
  50.             {
  51.               loader: 'css-loader',
  52.               options: {
  53.                 sourceMap: devMode
  54.               }
  55.             }
  56.           ]
  57.         }
  58.       ]
  59.     },
  60.     plugins: [
  61.       new MiniCssExtractPlugin({ filename: '../css/app.css' }),
  62.       new CopyWebpackPlugin([{ from: 'static/', to: '../' }])
  63.     ]
  64.   }
  65. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement