webpack-cli icon indicating copy to clipboard operation
webpack-cli copied to clipboard

Redundant \ in webpack.config.js generated by webpack init

Open logo749 opened this issue 5 years ago • 4 comments

Describe the bug

Redundant \ in webpack.config.js generated by webpack init which make the test condition never match. { test: /\\.(js|jsx)$/, loader: 'babel-loader', },

What is the current behavior?

babel-loader would't not be matched.

To Reproduce

  1. npm install --save webpack
  2. npx webpack init
  3. check the generated webpack.config.js

Expected behavior

Redundant \ in webpack.config.js

Screenshots

image

Please paste the results of webpack-cli info here, and mention other relevant information

System: OS: Windows 10 10.0.19041 CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz Memory: 15.94 GB / 31.78 GB Binaries: Node: 14.15.4 - D:\Work\bin\nodejs\node.EXE Yarn: 1.19.0 - ~\AppData\Roaming\npm\yarn.CMD npm: 6.14.6 - D:\Work\bin\nodejs\npm.CMD Browsers: Chrome: 89.0.4389.90 Edge: Spartan (44.19041.423.0) Internet Explorer: 11.0.19041.1 Packages: html-webpack-plugin: ^5.3.1 => 5.3.1 webpack: ^5.28.0 => 5.28.0 webpack-cli: ^4.6.0 => 4.6.0

logo749 avatar Mar 29 '21 03:03 logo749

Thanks

alexander-akait avatar Mar 29 '21 10:03 alexander-akait

Looking into it.

snitin315 avatar Mar 29 '21 11:03 snitin315

Running webpack-cli init in a fresh project this week introduces this redundant slash, which results in the following error when attempting to import some affected files:

Module parse failed: Unexpected token (1:36)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.

Removing the slash resolves this error. It took me a long time to track down (it's 2am now!) because I never expected the CLI to generate a faulty webpack.config.js. Can this fix be escalated into a release? This seriously harms a new user's experience, if I hadn't used webpack in the past I likely would have tried a different tool today out of frustration. Thank you!

sky-coding avatar Apr 10 '21 09:04 sky-coding

Yep, release will be in near future

alexander-akait avatar Apr 10 '21 12:04 alexander-akait