Skip to content

Commit cc706f1

Browse files
committed
css webpack configs wip
1 parent 406ec3b commit cc706f1

File tree

2 files changed

+80
-77
lines changed

2 files changed

+80
-77
lines changed
File renamed without changes.

ghcjs/miso-functora/webpack.config.js

Lines changed: 80 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const RemoveEmptyScriptsPlugin = require("webpack-remove-empty-scripts");
66
const path = require("path");
77
const fs = require("fs");
88

9-
const js = {
9+
const jsConfig = {
1010
entry: "./js/main.js",
1111
output: {
1212
path: __dirname + "/js",
@@ -33,83 +33,86 @@ const js = {
3333
],
3434
};
3535

36-
const cssInp = __dirname + "/css";
37-
const cssOut = __dirname + "/dist/css";
38-
const cssEntry = fs
39-
.readdirSync(cssInp)
40-
.filter((file) => file.endsWith(".css"))
41-
.filter((file) =>
42-
[
43-
"ads-gazette.css",
44-
"ads-notebook.css",
45-
"ads-medium.css",
46-
"scooter.css",
47-
"propeller.css",
48-
"motherplate.css",
49-
"boot-paper.css",
50-
"boot-readable.css",
51-
"flat-ui.css",
52-
"pandoc-scholar.css",
53-
"tui.css",
54-
"latex.css",
55-
"ok.css",
56-
"hello.css",
57-
"minimal.css",
58-
"siimple.css",
59-
"missing-style.css",
60-
"semantic-ui.css",
61-
"w3c-traditional.css",
62-
"primer.css",
63-
"yamb.css",
64-
].every((bad) => file != bad),
65-
)
66-
.map((file) => [path.basename(file, ".css"), path.join(cssInp, file)])
67-
.reduce(
68-
(entries, [name, filePath]) => ({ ...entries, [name]: filePath }),
69-
{},
70-
);
36+
function cssEntry(cssDir) {
37+
const input = __dirname + "/lib/" + cssDir;
38+
return fs
39+
.readdirSync(input)
40+
.filter((file) => file.endsWith(".css"))
41+
.filter((file) =>
42+
[
43+
"ads-gazette.css",
44+
"ads-notebook.css",
45+
"ads-medium.css",
46+
"scooter.css",
47+
"propeller.css",
48+
"motherplate.css",
49+
"boot-paper.css",
50+
"boot-readable.css",
51+
"flat-ui.css",
52+
"pandoc-scholar.css",
53+
"tui.css",
54+
"latex.css",
55+
"ok.css",
56+
"hello.css",
57+
"minimal.css",
58+
"siimple.css",
59+
"missing-style.css",
60+
"semantic-ui.css",
61+
"w3c-traditional.css",
62+
"primer.css",
63+
"yamb.css",
64+
].every((bad) => file != bad),
65+
)
66+
.map((file) => [path.basename(file, ".css"), path.join(input, file)])
67+
.reduce(
68+
(entries, [name, filePath]) => ({ ...entries, [name]: filePath }),
69+
{},
70+
);
71+
}
7172

72-
const css = {
73-
entry: cssEntry,
74-
output: {
75-
path: cssOut,
76-
clean: true,
77-
},
78-
mode: "production",
79-
optimization: {
80-
minimize: true,
81-
minimizer: [new CssMinimizerPlugin()],
82-
},
83-
plugins: [
84-
new MiniCssExtractPlugin({
85-
filename: "[name].min.css",
86-
}),
87-
new webpack.optimize.LimitChunkCountPlugin({
88-
maxChunks: 1,
89-
}),
90-
new RemoveEmptyScriptsPlugin(),
91-
],
92-
module: {
93-
rules: [
94-
{
95-
test: /\.css$/,
96-
use: [
97-
MiniCssExtractPlugin.loader,
98-
{ loader: "css-loader", options: { importLoaders: 1 } },
99-
{
100-
loader: "postcss-loader",
101-
options: { postcssOptions: { plugins: ["postcss-import-url"] } },
102-
},
103-
],
104-
},
73+
function cssConfig(cssDir) {
74+
return {
75+
entry: cssEntry(cssDir),
76+
output: {
77+
path: __dirname + "/dist/" + cssDir,
78+
clean: true,
79+
},
80+
mode: "production",
81+
optimization: {
82+
minimize: true,
83+
minimizer: [new CssMinimizerPlugin()],
84+
},
85+
plugins: [
86+
new MiniCssExtractPlugin({
87+
filename: "[name].min.css",
88+
}),
89+
new webpack.optimize.LimitChunkCountPlugin({
90+
maxChunks: 1,
91+
}),
92+
new RemoveEmptyScriptsPlugin(),
10593
],
106-
},
107-
experiments: {
108-
buildHttp: {
109-
allowedUris: [/^(http|https):\/\//],
110-
frozen: false,
94+
module: {
95+
rules: [
96+
{
97+
test: /\.css$/,
98+
use: [
99+
MiniCssExtractPlugin.loader,
100+
{ loader: "css-loader", options: { importLoaders: 1 } },
101+
{
102+
loader: "postcss-loader",
103+
options: { postcssOptions: { plugins: ["postcss-import-url"] } },
104+
},
105+
],
106+
},
107+
],
111108
},
112-
},
113-
};
109+
experiments: {
110+
buildHttp: {
111+
allowedUris: [/^(http|https):\/\//],
112+
frozen: false,
113+
},
114+
},
115+
};
116+
}
114117

115-
module.exports = [js, css];
118+
module.exports = [jsConfig, cssConfig("themes"), cssConfig("miso-functora")];

0 commit comments

Comments
 (0)