Val-Zhang / blogs

对编码生活的一些总结
353 stars 305 forks source link

在截取entry的时候获取fileName为undefined #4

Closed ghost closed 6 years ago

ghost commented 6 years ago

pages.forEach(function (pathname) { const fileName = pathname.split('\')[1]; //这里应该转译一下 反斜杠取不到 取到为undefined const conf = { filename: fileName + '.html', template: 'src' + pathname + '.html', inject: 'body', chunks: ['vendors', 'manifest', fileName] }; plugins.push(new HtmlWebpackPlugin(conf)); entry[fileName] = ./src/${pathname}.js; devServer.historyApiFallback.rewrites.push( {from: ${fileName}, to: /dist/${fileName}.html} ) });

Val-Zhang commented 6 years ago

应该是window和MacOS系统对路径的处理不同,windows下路径应该使用\,而MacOS下应该使用/,用的MacOS系统,之前没考虑windows下的这个问题