Closed SukkaW closed 1 year ago
After digging a little into Next.js and webpack-virtual-modules, it turns out that Next.js just doesn't work well with webpack-virtual-modules. And that's why it doesn't work on Next.js 13 appDir
.
I have started another project style9-webpack, re-implements style9's webpack plugin without using webpack-virtual-modules.
@TxHawks @Dwlad90 would you like to give style9-webpack
a shot?
@johanholmerin I am really willing to port my style9-webpack
implementation back to style9, but:
inlineLoader
option of Style9Plugin.loader
.virtualFileLoader
approach used in style9-webpack
is simple and has less overhead than webpack-virtual-modules, but it might be a little bit slower as virtualFileLoader
does extra serialization.If your new plugin works better I'd be happy to integrate it. As for the inline loaders, it consists of the name of the loader, followed by an question mark and options, an exclamation mark, and then the normal path, e.g. loader-name?{options}!./file.css
. Here's the best documentation I could find on it: https://webpack.js.org/concepts/loaders/#inline
If your new plugin works better I'd be happy to integrate it.
It does work for me.
As for the inline loaders, it consists of the name of the loader, followed by an question mark and options, an exclamation mark, and then the normal path, e.g.
loader-name?{options}!./file.css
. Here's the best documentation I could find on it: https://webpack.js.org/concepts/loaders/#inline
Because I am not familiar with inline loader syntax, I don't know where to put inlineLoader
(where css-loader
and MiniExtractPlugin.loader
would be). Is it right after !=!
or is it after virtualResourceLoader
?
I am closing this PR now, because:
webpack-virtual-modules
is working for everyone except Next.js appDir
users.
pages
dir (without appDir
), webpack-virtual-modules
still works for you.appDir
not only can't work with webpack-virtual-modules
, but also has some internal implementation quirk (Currently, it will drop all inline loaders when collecting styles in the Server Component, see https://github.com/SukkaW/style9-webpack/issues/1 for more information).style9
's codebase.I will continue doing some experiments in my style9-webpack repo, and then I will open other PRs to backport some of the features/optimizations.
cc @TxHawks @Dwlad90
Would you like to try the patch to see if it works?
Note the
appDir
might still not work, but the currentpages
is not affected (the behavior is retained, thus it is fully backward compatible).See also: