@@ -36,7 +36,9 @@ function getEntry(isNotebook) {
36
36
37
37
function getPlugins ( isNotebook ) {
38
38
const plugins = [ ] ;
39
- plugins . push ( ...common . getDefaultPlugins ( isNotebook ? 'notebook' : 'viewers' ) ) ;
39
+ if ( isProdBuild ) {
40
+ plugins . push ( ...common . getDefaultPlugins ( isNotebook ? 'notebook' : 'viewers' ) ) ;
41
+ }
40
42
41
43
if ( isNotebook ) {
42
44
plugins . push (
@@ -57,13 +59,15 @@ function getPlugins(isNotebook) {
57
59
} )
58
60
) ;
59
61
} else {
62
+ const definePlugin = new webpack . DefinePlugin ( {
63
+ 'process.env' : {
64
+ NODE_ENV : JSON . stringify ( 'production' )
65
+ }
66
+ } ) ;
67
+
60
68
plugins . push (
69
+ ...( isProdBuild ? [ definePlugin ] : [ ] ) ,
61
70
...[
62
- new webpack . DefinePlugin ( {
63
- 'process.env' : {
64
- NODE_ENV : JSON . stringify ( 'production' )
65
- }
66
- } ) ,
67
71
new HtmlWebpackPlugin ( {
68
72
template : 'src/datascience-ui/plot/index.html' ,
69
73
indexUrl : `${ constants . ExtensionRootDir } /out/1` ,
@@ -84,7 +88,9 @@ function getPlugins(isNotebook) {
84
88
}
85
89
86
90
function buildConfiguration ( isNotebook ) {
91
+ // Folder inside `datascience-ui` that will be created and where the files will be dumped.
87
92
const bundleFolder = isNotebook ? 'notebook' : 'viewers' ;
93
+
88
94
return {
89
95
context : constants . ExtensionRootDir ,
90
96
entry : getEntry ( isNotebook ) ,
@@ -96,8 +102,9 @@ function buildConfiguration(isNotebook) {
96
102
mode : 'development' , // Leave as is, we'll need to see stack traces when there are errors.
97
103
devtool : 'source-map' ,
98
104
optimization : {
99
- minimize : true ,
100
- minimizer : [ new TerserPlugin ( { sourceMap : true } ) ] ,
105
+ minimize : isProdBuild ,
106
+ minimizer : isProdBuild ? [ new TerserPlugin ( { sourceMap : true } ) ] : [ ] ,
107
+ moduleIds : 'hashed' , // (doesn't re-generate bundles unnecessarily) https://webpack.js.org/configuration/optimization/#optimizationmoduleids.
101
108
splitChunks : {
102
109
chunks : 'all' ,
103
110
cacheGroups : {
0 commit comments