refactor: style-loader in dev for HMR happiness

This commit is contained in:
cha0s 2022-03-13 14:37:59 -05:00
parent ee3719858a
commit 5fc4c897f6
2 changed files with 3 additions and 3 deletions

View File

@ -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,

View File

@ -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$/,