You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
module.rules.include forward slash in windows 10 #5327
Do you want to request a feature or report a bug?
Report a bug.
What is the current behavior?
Webpack doesn't use the module.rules.include option properly on windows 10.
If the current behavior is a bug, please provide the steps to reproduce.
module.exports={// ... removed for brevitymodule: {rules: [{test: /\.js$/,include: `${__dirname}/src`,use: [{loader: 'babel-loader',options: {presets: ['react'],plugins: ['transform-es2015-modules-commonjs']}}]}]},// ... removed for brevity};
Because I'm using a forward slash in include: `${__dirname}/src` , the path is actually not included when babel does its work. If I replace it with include: `${__dirname}\\src` , it works. However the entry option works just fine, which is entry: `${__dirname}/src/js/main.js` .
What is the expected behavior?
Webpack should treat forward slashes the same in the entry and module.rules.include options, meaning that forward slashes should work on windows the same as \\. If this is a feature request, what is motivation or use case for changing the behavior?
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
windows 10, webpack 3.3.0, node 6.9.1, npm 3.10.10
It would be nice if webpack could fix my incorrect slashes everywhere (since the solution for that is already there) as this would make it easy to use the same config on windows and linux.
Reacted by Leonidas Palyvas, Stanislav Goncharov, htbkoo, John McCarthy, Marko Žarković, Matyas Forian-Szabo, Grigorii K. Shartsev and Stephen Spencer
This unfortunately is the same with the module.rules.test which makes it difficult to use the most common use case; using a regex. You have to [\/\\] each directory 😞
Activity
sokra commentedon Jul 20, 2017
includematches the absolute path of the resolved file (see also https://webpack.js.org/configuration/module/#condition). Best usepath.resolve(__dirname, "src")as value toinclude.webpack automatically fixes your incorrect slashes for the entry option.
raulsebastianmihaila commentedon Jul 20, 2017
It would be nice if webpack could fix my incorrect slashes everywhere (since the solution for that is already there) as this would make it easy to use the same config on windows and linux.
rally25rs commentedon Mar 14, 2019
This unfortunately is the same with the
module.rules.testwhich makes it difficult to use the most common use case; using a regex. You have to[\/\\]each directory 😞