INFRA-1586 | use webpack serve instead of webpack-dev-serve, remove extract-text-webpack-plugin as it has been deprecated instead add MiniCssExtractPlugin

This commit is contained in:
dhruvjoshi
2024-02-09 18:07:38 +05:30
parent 55e117c2cb
commit 162f96257a
3 changed files with 477 additions and 364 deletions

View File

@@ -1,6 +1,6 @@
const path = require('path');
const HtmlPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
@@ -27,34 +27,33 @@ module.exports = {
},
module: {
rules: [{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-typescript",
],
},
},
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('css-loader'),
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-typescript",
],
},
},
},
{
test: /\.(sass|scss)$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader!sass-loader',
}),
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
{
test: /\.scss$/i,
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
},
],
},
plugins: [
new ExtractTextPlugin(`bundle.css?t=${new Date().getTime()}`),
new MiniCssExtractPlugin({
filename: `bundle.css?t=${new Date().getTime()}`,
}),
new HtmlPlugin({
template: './index.html',
}),
@@ -65,4 +64,4 @@ module.exports = {
watchOptions: {
ignored: /node_modules/,
},
};
};