File tree Expand file tree Collapse file tree 3 files changed +156
-145
lines changed Expand file tree Collapse file tree 3 files changed +156
-145
lines changed Original file line number Diff line number Diff line change 2626 },
2727 "author" : " " ,
2828 "license" : " Apache-2.0" ,
29+ "peerDependencies" : {
30+ "lodash" : " ^4.17.5" ,
31+ "radium" : " ^0.25.2" ,
32+ "react" : " ~15.4.0" ,
33+ "react-dom" : " ~15.4.0"
34+ },
2935 "devDependencies" : {
3036 "@tensorflow-models/knn-classifier" : " ~1.1.0" ,
3137 "@tensorflow-models/mobilenet" : " ^2.0.4" ,
5561 "identity-obj-proxy" : " ^3.0.0" ,
5662 "jest" : " ^15.0.0" ,
5763 "jquery" : " 1.12.1" ,
58- "jquery-ui" : " ^1.12.1" ,
59- "jquery-ui-touch-punch" : " ^0.2.3" ,
6064 "lodash" : " ^4.17.5" ,
6165 "mem" : " >=4.0.0" ,
6266 "node-fetch" : " ^2.6.0" ,
6367 "prettier" : " 1.16.1" ,
6468 "query-string" : " 4.1.0" ,
6569 "radium" : " ^0.25.2" ,
6670 "react" : " ~15.4.0" ,
67- "react-bootstrap" : " 0.30.1" ,
68- "react-color" : " ^2.17.3" ,
6971 "react-dom" : " ~15.4.0" ,
7072 "react-test-renderer" : " ~15.4.0" ,
7173 "style-loader" : " ^1.0.0" ,
7274 "svm" : " uponthesun/svmjs" ,
7375 "url-loader" : " ^2.2.0" ,
7476 "webpack" : " 4.19.1" ,
77+ "webpack-bundle-analyzer" : " ^3.6.0" ,
7578 "webpack-cli" : " ^3.3.6" ,
7679 "webpack-dev-server" : " ^3.1.4" ,
7780 "yargs" : " ^14.0.0"
Original file line number Diff line number Diff line change 11const { CleanWebpackPlugin } = require ( 'clean-webpack-plugin' ) ;
22const CopyPlugin = require ( 'copy-webpack-plugin' ) ;
33
4- module . exports = {
4+ const commonConfig = {
55 devtool : 'eval-cheap-module-source-map' ,
66 resolve : {
77 extensions : [ '.js' , '.jsx' ] ,
88 } ,
9- entry : {
10- assetPath : './src/demo/assetPath.js' ,
11- main : './src/index.js' ,
12- demo : './src/demo/index.jsx' ,
13- } ,
149 output : {
1510 filename : '[name].js' ,
1611 libraryTarget : 'umd' ,
@@ -76,7 +71,10 @@ module.exports = {
7671 } ,
7772 maxAssetSize : 300000 ,
7873 maxEntrypointSize : 10500000 ,
79- } ,
74+ }
75+ } ;
76+
77+ const firstConfigOnly = {
8078 plugins : [
8179 new CleanWebpackPlugin ( ) ,
8280 new CopyPlugin ( [ {
@@ -86,3 +84,50 @@ module.exports = {
8684 } ] ) ,
8785 ] ,
8886} ;
87+
88+ const externalConfig = {
89+ externals : {
90+ "lodash" : "lodash" ,
91+ "radium" : "radium" ,
92+ "react" : "react" ,
93+ "react-dom" : "react-dom" ,
94+ }
95+ } ;
96+
97+ const defaultConfig = [
98+ {
99+ entry : {
100+ assetPath : './src/demo/assetPath.js'
101+ } ,
102+ ...commonConfig ,
103+ ...firstConfigOnly ,
104+ ...externalConfig
105+ } ,
106+ {
107+ entry : {
108+ demo : './src/demo/index.jsx'
109+ } ,
110+ ...commonConfig
111+ }
112+ ] ;
113+
114+ const productionConfig = [
115+ {
116+ entry : {
117+ main : './src/index.js'
118+ } ,
119+ ...commonConfig ,
120+ ...externalConfig
121+ }
122+ ] ;
123+
124+ module . exports = ( env , argv ) => {
125+ if ( argv . mode === 'production' ) {
126+ return [
127+ ...defaultConfig ,
128+ ...productionConfig ,
129+ ] ;
130+ }
131+
132+ return defaultConfig ;
133+ } ;
You can’t perform that action at this time.
0 commit comments