Closed ghost closed 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} ) });
./src/${pathname}.js
${fileName}
/dist/${fileName}.html
应该是window和MacOS系统对路径的处理不同,windows下路径应该使用\,而MacOS下应该使用/,用的MacOS系统,之前没考虑windows下的这个问题
\
/
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
} ) });