`module.rules.include` forward slash in windows 10

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 brevity
  module: {
    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

Author: Fantashit

1 thought on “`module.rules.include` forward slash in windows 10

  1. 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.

Comments are closed.