mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2025-01-03 01:16:14 +03:00
Fix AddFile plugin so that it correctly adds files that work in dev mode.
This commit is contained in:
parent
3b64034764
commit
76c91d6108
@ -17,13 +17,15 @@ class AddFilesPlugin {
|
||||
apply(compiler) {
|
||||
compiler.hooks.afterCompile.tap("AddFilesPlugin", compilation => {
|
||||
this.filesList.forEach(file => {
|
||||
compilation.assets[path.join(file.name, "content.txt")] = {
|
||||
source: function() {
|
||||
return file.content;
|
||||
},
|
||||
size: function() {
|
||||
file.content.length;
|
||||
}
|
||||
// Couldn't find this documented in the webpack docs,
|
||||
// but I found the example code for it here:
|
||||
// https://github.com/jantimon/html-webpack-plugin/blob/35a154186501fba3ecddb819b6f632556d37a58f/index.js#L470-L478
|
||||
|
||||
const filename = path.join(file.name, "content.txt");
|
||||
compilation.fileDependencies.add(filename);
|
||||
compilation.assets[filename] = {
|
||||
source: () => file.content,
|
||||
size: () => file.content.size
|
||||
};
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user