-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix break: use regexp to detect css-loader #68
Fix break: use regexp to detect css-loader #68
Conversation
Actually I knew this may happen, but wasn't sure. Let's think about why does |
@halt-hammerzeit Yes, you are right. |
From which folder are you running Webpack? |
This is my folder structure
I run webpack from the root of the project. Actually, I wrote a node script in package.json. // package.json
{
"scripts": {
"build:client": "webpack ./src/webpack/webpack.config.babel.js"
}
} and run
|
I don't see why does webpack take the css loader from the parent folder ( |
I'm out for lunch, will be online in an hour |
Right! This is my config: // in webpack.config.babel.js
module.exports = {
devtool: DEV ? 'source-map' : false,
context: path.resolve(__dirname, '..'),
entry: {
main: './client',
},
... The context is |
Confirmed! After I removed the context from webpack config, and changed entry to
And then I tried to change the context to
|
When you do |
No, the context can't be // `/webpack-assets.json`
{
"javascript": {
"main": "http://localhost:3001/project/assets/sp/20160414-ad47ad8/main.js"
},
"styles": {},
"assets": {
"./src/components/Header/HeaderUserInfo.css": {
"thumbProf": "thumbProf___3UeI_",
"thumbImg": "thumbImg___AfLtz",
}
}
... In the production environment, all the /src will be compiled to /target by babel for server side.
|
Yes Currently there's no ready solution for If you want to make the new version work as the old one you can try to set your context to |
Thank you! I have already used this patch in my project and it works as expected. |
Ok, I'm closing this PR then. |
@halt-hammerzeit I will propose another solution later. |
@kouhin You said 2.2.45 works now for your project with the Your solution would work for I've modified the current solution a bit. |
No, I just use a customized filter to make the build work.
I have noticed this pattern, so I use The problem of this solution, is that the regexp can find all loaders within the module.name. It's not necessary and resulted in a bad performance. Maybe this would be better. Webpack_isomorphic_tools_plugin.style_loader_filter = function(module, regular_expression, options, log)
{
const css_loader = module.name.split('!')[0]
return /\/css-loader[\?!@]/.test(css_loader);
} |
Thank you for the new version, I will try it tomorrow. |
@kouhin can you explain how you made this work? I also like to precompile my code, in my case from What did you put as |
This is my folder structure:
This is partial config in module.exports = {
context: path.resolve(__dirname, '..'), // Make context root to /src
entry: {
main: './client', // This is /src/client.js
},
output: {
path: path.resolve(__dirname, '..', '..', 'build', version),
publicPath: `${CDN_PATH}/${version}/`,
filename: '[name].js',
chunkFilename: '[id].js',
},
...
plugins: [
//... other plugins
webpackIsomorphicToolsPlugin.development(DEV),
] Actually, in style_modules: {
extensions: ['css'],
filter: function styleFilter(module, regex, options) {
if (options.development) {
const loader = module.name.split('!')[0];
return /\/css-loader[\?!@]/.test(loader);
}
return regex.test(module.name);
},
path: function stylePath(module, options, log) {
if (options.development) {
return WebpackIsomorphicToolsPlugin.style_loader_path_extractor(module, options, log);
}
return module.name;
},
parser: function styleParser(module, options, log) {
if (options.development) {
return WebpackIsomorphicToolsPlugin.css_modules_loader_parser(module, options, log);
}
return module.source;
},
}, Build step:
Hope this helps! |
Awesome! Thanks for the very elaborated response 😄 That’s definitely helpful, I can’t wait to try this later today! |
FYI |
@kouhin running into this problem too. I cannot get the paths in webpack-assets.json to change from Thoughts? |
@mmahalwy So have you tried copying assets from |
@mmahalwy, using @kouhin's instructions I got it to work here: |
@halt-hammerzeit yes, all assets are copied over. The problem is that my webpack-assets.json still references |
@mmahalwy If you didn't get it, what HOU Bin proposed is to set Webpack module.exports = {
context: path.resolve(__dirname, '..'), // Make context root to /src
} The fact that all assets in your |
Yes, and once i change the context to But regardless, I want them to point to |
@mmahalwy Define "fails" |
Okay, I got it to work. It was 'failing' or not compiling because of the entry files still had reference to Thanks alot folks! |
v2.2.45 breaks my build absolutely!
I use the following code to check out the differences between v2.2.44 and v2.2.45,
Output:
So I create this PR to fix this issue.
It use regular expression to find the first loader, when the first loader is
css-loader
, true will be returned.@halt-hammerzeit