Skip to content

Commit 2df5d06

Browse files
committed
use MiniCssExtractPlugin to load extract CSS styles from JS
1 parent a9d4e99 commit 2df5d06

File tree

4 files changed

+133
-5
lines changed

4 files changed

+133
-5
lines changed

frontend/package-lock.json

Lines changed: 123 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"copy-webpack-plugin": "^11.0.0",
2222
"css-loader": "^6.7.1",
2323
"html-webpack-plugin": "^5.5.0",
24+
"mini-css-extract-plugin": "^2.6.0",
2425
"postcss": "^8.4.14",
2526
"postcss-loader": "^7.0.0",
2627
"sass": "^1.52.3",

frontend/webpack.common.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const path = require("path");
22
const HtmlWebpackPlugin = require("html-webpack-plugin");
33
const CopyPlugin = require("copy-webpack-plugin");
4+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
45

56
module.exports = {
67
entry: "./src/index.ts",
@@ -17,7 +18,8 @@ module.exports = {
1718
patterns: [
1819
{ from: "img/*", to: "" }
1920
],
20-
}),
21+
}),
22+
new MiniCssExtractPlugin()
2123
],
2224
resolve: {
2325
modules: ["node_modules"],
@@ -32,11 +34,12 @@ module.exports = {
3234
},
3335
{
3436
test: /\.(scss)$/,
35-
use: [{
36-
loader: "style-loader", // inject CSS to page
37-
}, {
37+
use: [
38+
MiniCssExtractPlugin.loader,
39+
{
3840
loader: "css-loader", // translates CSS into CommonJS modules
39-
}, {
41+
},
42+
{
4043
loader: "postcss-loader", // Run post css actions
4144
options: {
4245
postcssOptions: {

frontend/webpack.prod.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ const common = require("./webpack.common.js");
33

44
module.exports = merge(common, {
55
mode: "production",
6+
devtool: "source-map",
67
});

0 commit comments

Comments
 (0)