Skip to content

Commit

Permalink
use MiniCssExtractPlugin to load extract CSS styles from JS
Browse files Browse the repository at this point in the history
  • Loading branch information
stv0g committed Jun 12, 2022
1 parent a9d4e99 commit 2df5d06
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 5 deletions.
123 changes: 123 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.1",
"html-webpack-plugin": "^5.5.0",
"mini-css-extract-plugin": "^2.6.0",
"postcss": "^8.4.14",
"postcss-loader": "^7.0.0",
"sass": "^1.52.3",
Expand Down
13 changes: 8 additions & 5 deletions frontend/webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

module.exports = {
entry: "./src/index.ts",
Expand All @@ -17,7 +18,8 @@ module.exports = {
patterns: [
{ from: "img/*", to: "" }
],
}),
}),
new MiniCssExtractPlugin()
],
resolve: {
modules: ["node_modules"],
Expand All @@ -32,11 +34,12 @@ module.exports = {
},
{
test: /\.(scss)$/,
use: [{
loader: "style-loader", // inject CSS to page
}, {
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader", // translates CSS into CommonJS modules
}, {
},
{
loader: "postcss-loader", // Run post css actions
options: {
postcssOptions: {
Expand Down
1 change: 1 addition & 0 deletions frontend/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ const common = require("./webpack.common.js");

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

0 comments on commit 2df5d06

Please sign in to comment.