Skip to content

Commit 3f670a4

Browse files
prateekbhlukeed
authored andcommitted
don't build service-worker if flagged (#500)
* fixing imports * re-include \.git* sw-ignores
1 parent e910aa9 commit 3f670a4

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/lib/webpack/webpack-client-config.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function clientConfig(env) {
9595
function isProd(config) {
9696
let limit = 200 * 1000; // 200kb
9797

98-
return {
98+
const prodConfig = {
9999
performance: {
100100
hints: 'warning',
101101
maxAssetSize: limit,
@@ -139,6 +139,14 @@ function isProd(config) {
139139
]
140140
}
141141
}),
142+
new webpack.DefinePlugin({
143+
'process.env.ADD_SW': config.serviceWorker
144+
}),
145+
]
146+
};
147+
148+
if (config.serviceWorker) {
149+
prodConfig.plugins.push(
142150
new SWPrecacheWebpackPlugin({
143151
filename: 'sw.js',
144152
navigateFallback: 'index.html',
@@ -153,11 +161,10 @@ function isProd(config) {
153161
/\.git/
154162
]
155163
}),
156-
new webpack.DefinePlugin({
157-
'process.env.ADD_SW': config.serviceWorker
158-
}),
159-
]
160-
};
164+
);
165+
}
166+
167+
return prodConfig;
161168
}
162169

163170
function isDev(config) {

0 commit comments

Comments
 (0)