@@ -7,137 +7,125 @@ const TerserJSPlugin = require("terser-webpack-plugin");
77const webpack = require ( "webpack" ) ;
88
99module . exports = ( env , argv ) => {
10- const isDebug = ( argv . mode === "development" ) ;
10+ const isDebug = ( argv . mode === "development" ) ;
1111
12- const general_options = {
13- mode : ( isDebug ? "development" : "production" ) ,
14- optimization : {
15- minimizer : ( isDebug ? [ ] : [ new TerserJSPlugin ( { } ) , new OptimizeCSSAssetsPlugin ( ) ] ) ,
16- }
17- } ;
12+ const general_options = {
13+ mode : ( isDebug ? "development" : "production" ) ,
14+ optimization : {
15+ minimizer : ( isDebug ? [ ] : [ new TerserJSPlugin ( { } ) , new OptimizeCSSAssetsPlugin ( ) ] ) ,
16+ }
17+ } ;
1818
19- const browser_options = {
20- ...general_options ,
21- resolve : {
22- alias : {
23- fs : __dirname + "/src/fs_browser_null.js" ,
24- "fs-extra" : __dirname + "/src/fs_browser_null.js" ,
25- "graceful-fs" : __dirname + "/src/fs_browser_null.js" ,
26- path : "path-browserify" , // Latest version which supports `path.parse`
27- readdirp : __dirname + "/src/fs_browser_null.js"
28- }
29- } ,
30- target : "web"
31- } ;
19+ const browser_options = {
20+ ...general_options ,
21+ resolve : {
22+ alias : {
23+ fs : __dirname + "/src/fs_browser_null.js" ,
24+ "fs-extra" : __dirname + "/src/fs_browser_null.js" ,
25+ "graceful-fs" : __dirname + "/src/fs_browser_null.js" ,
26+ path : "path-browserify" , // Latest version which supports `path.parse`
27+ readdirp : __dirname + "/src/fs_browser_null.js"
28+ }
29+ } ,
30+ target : "web"
31+ } ;
3232
33- return [
34- {
35- ...general_options ,
36- entry : {
37- index : "./src/index.js" ,
38- cli : "./src/cli.js"
39- } ,
40- output : {
41- filename : "[name].js" ,
42- path : __dirname + "/dist" ,
43- libraryTarget : "umd"
44- } ,
45- plugins : [
46- new webpack . BannerPlugin ( {
47- banner : "#!/usr/bin/env node" ,
48- raw : true ,
49- exclude : "*" ,
50- include : "cli.js"
51- } ) ,
52- ] ,
53- target : "node"
54- } ,
55- {
56- ...browser_options ,
57- entry : {
58- browser : "./src/index.js"
59- } ,
60- output : {
61- filename : "[name].js" ,
62- path : __dirname + "/dist" ,
63- libraryTarget : "umd" ,
64- globalObject : "this" // Fix worker
65- }
66- } ,
67- {
68- ...browser_options ,
69- entry : {
70- index : "./src/webapp/js/index.js"
71- } ,
72- module : {
73- rules : [
74- {
75- test : / \. l e s s $ / ,
76- use : [ MiniCssExtractPlugin . loader , "css-loader" , "less-loader" ]
77- } ,
78- {
79- test : / w o r k e r \. j s $ / ,
80- loader : "worker-loader" ,
81- options : {
82- name : "[name].[ext]"
83- }
84- }
85- ]
86- } ,
87- output : {
88- filename : "index.js" ,
89- path : __dirname + "/dist/webapp" ,
90- globalObject : "this" // Fix worker
91- } ,
92- plugins : [
93- new HtmlWebpackPlugin ( {
94- minify : ( isDebug ? false : {
95- collapseWhitespace : true ,
96- removeComments : true ,
97- removeRedundantAttributes : true ,
98- removeScriptTypeAttributes : true ,
99- removeStyleLinkTypeAttributes : true ,
100- useShortDoctype : true
101- } ) ,
102- template : "./src/webapp/html/index.html"
103- } ) ,
104- new MiniCssExtractPlugin ( ) ,
105- new FaviconsWebpackPlugin ( {
106- devMode : "webapp" ,
107- logo : "./src/webapp/img/icon.svg" ,
108- mode : "webapp" ,
109- favicons : {
110- appDescription : PACKAGE . description ,
111- appName : PACKAGE . productName ,
112- appShortName : PACKAGE . productName ,
113- appleStatusBarStyle : "black" ,
114- background : "#FFFFFF" ,
115- developerName : PACKAGE . author ,
116- developerURL : null ,
117- dir : null ,
118- display : "standalone" ,
119- icons : {
120- android : true ,
121- appleIcon : true ,
122- favicons : true ,
123- appleStartup : false ,
124- coast : false ,
125- firefox : false ,
126- windows : false ,
127- yandex : false
128- } ,
129- lang : null ,
130- manifestRelativePaths : true ,
131- orientation : "any" ,
132- path : "./" ,
133- start_url : ".." ,
134- theme_color : "#795548" ,
135- version : PACKAGE . version
136- } ,
137- prefix : "webapp" ,
138- publicPath : "./"
139- } )
140- ]
141- }
142- ] ;
33+ return [
34+ {
35+ ...general_options ,
36+ entry : {
37+ index : "./src/index.js" ,
38+ cli : "./src/cli.js"
39+ } ,
40+ output : {
41+ filename : "[name].js" ,
42+ path : __dirname + "/dist" ,
43+ libraryTarget : "umd"
44+ } ,
45+ plugins : [
46+ new webpack . BannerPlugin ( {
47+ banner : "#!/usr/bin/env node" ,
48+ raw : true ,
49+ exclude : "*" ,
50+ include : "cli.js"
51+ } ) ,
52+ ] ,
53+ target : "node"
54+ } ,
55+ {
56+ ...browser_options ,
57+ entry : {
58+ index : "./src/webapp/js/index.js"
59+ } ,
60+ module : {
61+ rules : [
62+ {
63+ test : / \. l e s s $ / ,
64+ use : [ MiniCssExtractPlugin . loader , "css-loader" , "less-loader" ]
65+ } ,
66+ {
67+ test : / w o r k e r \. j s $ / ,
68+ loader : "worker-loader" ,
69+ options : {
70+ name : "[name].[ext]"
71+ }
72+ }
73+ ]
74+ } ,
75+ output : {
76+ filename : "index.js" ,
77+ path : __dirname + "/dist/webapp" ,
78+ globalObject : "this" // Fix worker
79+ } ,
80+ plugins : [
81+ new HtmlWebpackPlugin ( {
82+ minify : ( isDebug ? false : {
83+ collapseWhitespace : true ,
84+ removeComments : true ,
85+ removeRedundantAttributes : true ,
86+ removeScriptTypeAttributes : true ,
87+ removeStyleLinkTypeAttributes : true ,
88+ useShortDoctype : true
89+ } ) ,
90+ template : "./src/webapp/html/index.html"
91+ } ) ,
92+ new MiniCssExtractPlugin ( ) ,
93+ new FaviconsWebpackPlugin ( {
94+ devMode : "webapp" ,
95+ logo : "./src/webapp/img/icon.svg" ,
96+ mode : "webapp" ,
97+ favicons : {
98+ appDescription : PACKAGE . description ,
99+ appName : PACKAGE . productName ,
100+ appShortName : PACKAGE . productName ,
101+ appleStatusBarStyle : "black" ,
102+ background : "#FFFFFF" ,
103+ developerName : PACKAGE . author ,
104+ developerURL : null ,
105+ dir : null ,
106+ display : "standalone" ,
107+ icons : {
108+ android : true ,
109+ appleIcon : true ,
110+ favicons : true ,
111+ appleStartup : false ,
112+ coast : false ,
113+ firefox : false ,
114+ windows : false ,
115+ yandex : false
116+ } ,
117+ lang : null ,
118+ manifestRelativePaths : true ,
119+ orientation : "any" ,
120+ path : "./" ,
121+ start_url : ".." ,
122+ theme_color : "#795548" ,
123+ version : PACKAGE . version
124+ } ,
125+ prefix : "webapp" ,
126+ publicPath : "./"
127+ } )
128+ ]
129+ }
130+ ] ;
143131} ;
0 commit comments