web/webpack.config.js
changeset 1558 761ba7426984
child 1583 459a88818bec
equal deleted inserted replaced
1557:7c67caaafdeb 1558:761ba7426984
       
     1 const path = require('path');
       
     2 const webpack = require('webpack');
       
     3 
       
     4 const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
       
     5 
       
     6 const nodeModulesPath = path.resolve(__dirname, 'node_modules');
       
     7 
       
     8 module.exports = {
       
     9   entry: [
       
    10     __dirname + '/src/js/index.js',
       
    11     __dirname + '/src/css/main.scss',
       
    12     __dirname + '/src/css/common.scss',
       
    13     __dirname + '/src/css/vendors.scss',
       
    14     
       
    15   ],
       
    16   output: {
       
    17     filename: 'live-polemic.js',
       
    18     path: path.resolve(__dirname, 'res/js'),
       
    19   },
       
    20   plugins: [
       
    21     new webpack.ProvidePlugin({
       
    22         $: "jquery",
       
    23         jQuery: "jquery",
       
    24     })
       
    25   ],
       
    26 //  devtool: 'eval',
       
    27   optimization: {
       
    28     minimizer: [
       
    29       // For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
       
    30       `...`,
       
    31       new CssMinimizerPlugin(),
       
    32     ],
       
    33     minimize: true,
       
    34   },
       
    35   module: {
       
    36     rules: [
       
    37       {
       
    38         test: /\.s?css$/,
       
    39         exclude: [ "/res/css" ],
       
    40 
       
    41         type: 'asset/resource',
       
    42         generator: {
       
    43           filename: '../css/[name].css'
       
    44         },
       
    45         use: [
       
    46           'resolve-url-loader',
       
    47           {
       
    48             loader: 'sass-loader',
       
    49             options: {
       
    50               sourceMap: true,
       
    51               // sassOptions: {
       
    52               //   includePaths: [nodeModulesPath],
       
    53               // },
       
    54             }
       
    55           },
       
    56         ]
       
    57       },
       
    58       {
       
    59         test: /\.(eot|ttf|woff|woff2)$/i,
       
    60         // More information here https://webpack.js.org/guides/asset-modules/
       
    61         type: "asset",
       
    62         generator: {
       
    63           filename: '../emits/fonts/[hash][ext][query]'
       
    64         },
       
    65       },
       
    66       {
       
    67         test: /\.(png|jpe?g|gif|svg)$/i,
       
    68         // More information here https://webpack.js.org/guides/asset-modules/
       
    69         type: "asset",
       
    70         generator: {
       
    71           filename: '../emits/images/[hash][ext][query]'
       
    72         },
       
    73 
       
    74       },
       
    75     ]
       
    76   }
       
    77 
       
    78 };