From 8af8f854e5fc1c6a960baf80fa1b439780a4a2e8 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 7 Mar 2023 11:58:50 +0300 Subject: Compile legacy with webpack --- webpack.config.js | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'webpack.config.js') diff --git a/webpack.config.js b/webpack.config.js index 0cf69606..c94ca661 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,6 +2,7 @@ const ESLintPlugin = require('eslint-webpack-plugin'); const CopyPlugin = require('copy-webpack-plugin'); +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const TerserPlugin = require('terser-webpack-plugin'); module.exports = (env, argv) => { @@ -12,7 +13,8 @@ module.exports = (env, argv) => { devtool: dev ? 'source-map' : false, entry: { 'scripts': [ - __dirname + '/src/main/assets/scripts.js' + __dirname + '/src/main/assets/scripts.js', + __dirname + '/src/main/assets/style.css' ] }, output: { @@ -28,6 +30,39 @@ module.exports = (env, argv) => { /\bwebpack\/buildin\b/ ], loader: 'babel-loader' + }, { + test: /\.(css)$/, + use: [ + { + loader: dev ? 'style-loader' : MiniCssExtractPlugin.loader, + }, + { + loader: 'css-loader', + options: { + sourceMap: true, + }, + }, + { + loader: 'postcss-loader', + options: { + postcssOptions: { + plugins: [ + [ + 'postcss-preset-env', + { + 'stage': 0 + }, + 'stylelint', + 'autoprefixer', + { + 'grid': true + } + ], + ], + }, + }, + }, + ], }] }, plugins: [ @@ -52,6 +87,8 @@ module.exports = (env, argv) => { failOnError: true, fix: false })); + } else { + config.plugins.push(new MiniCssExtractPlugin()); } config.optimization = { minimize: !dev, -- cgit v1.2.3