Skip to content

Commit 2573899

Browse files
committed
Fixing windows problems with \ in paths
1 parent 27f3534 commit 2573899

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/config-generator.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,11 @@ class ConfigGenerator {
128128
* See shared-entry-concat-plugin.js for more details.
129129
*/
130130
const tmpFileObject = tmp.fileSync();
131+
const pathToRequire = path.resolve(this.webpackConfig.getContext(), this.webpackConfig.sharedCommonsEntryFile);
131132
fs.writeFileSync(
132133
tmpFileObject.name,
133-
// quotes in the filename would cause problems
134-
`require('${path.resolve(this.webpackConfig.getContext(), this.webpackConfig.sharedCommonsEntryFile)}')`
134+
// escape single quotes (x27) and backslashes
135+
`require('${pathToRequire.replace(/\x27/g, '\\\x27').replace('/\\/g', '\\\\')}')`
135136
);
136137

137138
entry[sharedEntryTmpName] = tmpFileObject.name;

0 commit comments

Comments
 (0)