Skip to content

Commit

Permalink
Fix static folder destination on Windows
Browse files Browse the repository at this point in the history
On Windows, a file in static/file.txt was put into dist/static/file.txt instead of dist/file.txt.

This was because we cut off everything before the first "/" in the target path string, but Windows separates folders with "\".

Instead, we can use the somewhat hidden context feature from the CopyPlugin to get rid of the static/ prefix. See https://webpack.js.org/plugins/copy-webpack-plugin/#from-is-a-glob
  • Loading branch information
j-maas committed Jun 12, 2020
1 parent 716e71c commit e34c7ca
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions generator/src/develop.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,10 @@ function webpackOptions(
new AddFilesPlugin(),
new CopyPlugin([
{
from: "static/**/*",
transformPath(targetPath, absolutePath) {
// TODO this is a hack... how do I do this with proper config of `to` or similar?
return targetPath.substring(targetPath.indexOf("/") + 1);
}
// from inside the static folder
context: "static/",
// copy everything
from: "**/*",
}
]),
new CopyPlugin([
Expand Down

0 comments on commit e34c7ca

Please sign in to comment.