From 5fc4c897f6374e704bee59e1b9de350d5f8d1e9f Mon Sep 17 00:00:00 2001 From: cha0s Date: Sun, 13 Mar 2022 14:37:59 -0500 Subject: [PATCH] refactor: style-loader in dev for HMR happiness --- packages/http/src/server/build/http.neutrinorc.js | 2 +- packages/http/src/server/index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/http/src/server/build/http.neutrinorc.js b/packages/http/src/server/build/http.neutrinorc.js index 3bf1469..dea8412 100644 --- a/packages/http/src/server/build/http.neutrinorc.js +++ b/packages/http/src/server/build/http.neutrinorc.js @@ -60,7 +60,7 @@ module.exports = (async () => { const styleChunk = compilation.chunks.find((chunk) => ( chunk.chunkReason?.match(/split chunk \(cache group: styles\)/) )); - if (styleChunk) { + if (isProduction && styleChunk) { const modules = styleChunk.getModules(); const styleFileHref = join( compilation.options.output.publicPath, diff --git a/packages/http/src/server/index.js b/packages/http/src/server/index.js index 77dd8d8..537675a 100644 --- a/packages/http/src/server/index.js +++ b/packages/http/src/server/index.js @@ -17,13 +17,13 @@ export default { neutrino.use( styleLoader({ extract: { - enabled: 'http' === target, + enabled: isProduction && 'http' === target, }, modules: { localIdentName: isProduction ? '[hash]' : '[path][name]__[local]', }, style: { - injectType: 'lazyStyleTag', + injectType: 'http' === target ? 'styleTag' : 'lazyStyleTag', }, test: /\.(c|s[ac])ss$/, modulesTest: /\.module\.(c|s[ac])ss$/,