@@ -6,7 +6,7 @@ const RemoveEmptyScriptsPlugin = require("webpack-remove-empty-scripts");
6
6
const path = require ( "path" ) ;
7
7
const fs = require ( "fs" ) ;
8
8
9
- const js = {
9
+ const jsConfig = {
10
10
entry : "./js/main.js" ,
11
11
output : {
12
12
path : __dirname + "/js" ,
@@ -33,83 +33,86 @@ const js = {
33
33
] ,
34
34
} ;
35
35
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
+ }
71
72
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 : / \. c s s $ / ,
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 ( ) ,
105
93
] ,
106
- } ,
107
- experiments : {
108
- buildHttp : {
109
- allowedUris : [ / ^ ( h t t p | h t t p s ) : \/ \/ / ] ,
110
- frozen : false ,
94
+ module : {
95
+ rules : [
96
+ {
97
+ test : / \. c s s $ / ,
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
+ ] ,
111
108
} ,
112
- } ,
113
- } ;
109
+ experiments : {
110
+ buildHttp : {
111
+ allowedUris : [ / ^ ( h t t p | h t t p s ) : \/ \/ / ] ,
112
+ frozen : false ,
113
+ } ,
114
+ } ,
115
+ } ;
116
+ }
114
117
115
- module . exports = [ js , css ] ;
118
+ module . exports = [ jsConfig , cssConfig ( "themes" ) , cssConfig ( "miso-functora" ) ] ;
0 commit comments