Closed chenxsan closed 6 years ago
To debug, here is a diff of the --inspect
when running with extract
as default vs. extract: false
:
diff --git a/a.diff b/b.diff
index 99e32af..cb39e1e 100644
--- a/a.diff
+++ b/b.diff
@@ -126,7 +126,13 @@ $ neutrino build --inspect
loader: '/Users/eli/code/neutrino-dev/node_modules/style-loader/index.js'
},
{
- loader: '/Users/eli/code/neutrino-dev/node_modules/css-hot-loader/index.js'
+ loader: '/Users/eli/code/neutrino-dev/node_modules/css-loader/index.js',
+ options: {
+ importLoaders: 0
+ }
+ },
+ {
+ loader: '/Users/eli/code/neutrino-dev/node_modules/style-loader/index.js'
},
{
loader: '/Users/eli/code/neutrino-dev/node_modules/css-loader/index.js',
@@ -156,7 +162,14 @@ $ neutrino build --inspect
loader: '/Users/eli/code/neutrino-dev/node_modules/style-loader/index.js'
},
{
- loader: '/Users/eli/code/neutrino-dev/node_modules/css-hot-loader/index.js'
+ loader: '/Users/eli/code/neutrino-dev/node_modules/css-loader/index.js',
+ options: {
+ importLoaders: 0,
+ modules: true
+ }
+ },
+ {
+ loader: '/Users/eli/code/neutrino-dev/node_modules/style-loader/index.js'
},
{
loader: '/Users/eli/code/neutrino-dev/node_modules/css-loader/index.js',
@@ -611,4 +624,4 @@ $ neutrino build --inspect
},
target: 'web'
}
-Done in 1.75s.
+Done in 1.78s.
A couple things I notice:
Ah, found the issue!
When we make a first pass at loading the style middleware through the react-components
middleware, all the extract options are true, so the associated plugins for extraction are enabled. When you add the style-loader
middleware again, all the original plugins for style loading are overridden, but the extraction ones are not, because they are skipped!
The easiest solution here would then be to change the style options in the original react-components middleware, and not add another instance of style-loader:
module.exports = {
use: [
['@neutrinojs/react-components', {
manifest: {},
style: {
loaders: [
'postcss-loader'
],
extract: false
}
}],
]
};
@chenxsan Give that a shot!
Closing with the previous comment as the solution. Please feel free to re-open if the solution does not work as intended. Thanks!
I would love to disable
extract
in one of my project, but got this error when I runyarn build
:Here's my code:
And my
.neutrinorc.js
:Also I just setup a git repo here.