-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
39 lines (36 loc) · 1.03 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const fs = require('fs');
const projectRoot = __dirname;
const cssSourceRoot = projectRoot + "/css"
function findAllCssExtensions(dir) {
const extensions = [];
const files = fs.readdirSync(dir);
files.forEach(file => {
const filePath = `${dir}/${file}`;
const stat = fs.statSync(filePath);
if (stat.isDirectory()) {
extensions.push(...findAllCssExtensions(filePath));
} else if ((file.endsWith('.css') || file.endsWith('.scss')) && !file.endsWith("tailwind_base.css")) {
extensions.push(filePath);
}
});
return extensions;
}
const entryMap = findAllCssExtensions(cssSourceRoot); // run tailwind builder before this
module.exports = {
mode: "development",
entry: entryMap,
output: {
path: projectRoot + "/dist/css",
filename: "style.js",
},
plugins: [new MiniCssExtractPlugin()],
module: {
rules: [
{
test: /\.(scss|css)$/i,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
],
},
};