[FEATURE] Make plugin always write asset constants file to disk
This commit is contained in:
parent
9c41548be6
commit
f796aae834
20
index.js
20
index.js
@ -1,4 +1,7 @@
|
|||||||
const cheerio = require('cheerio')
|
const cheerio = require('cheerio')
|
||||||
|
var mkdirp = require('mkdirp');
|
||||||
|
var fs = require('fs');
|
||||||
|
var path = require('path');
|
||||||
|
|
||||||
function HtmlWebpackAlterDataPlugin (options) {
|
function HtmlWebpackAlterDataPlugin (options) {
|
||||||
this.options = {
|
this.options = {
|
||||||
@ -112,6 +115,23 @@ HtmlWebpackAlterDataPlugin.prototype.apply = function (compiler) {
|
|||||||
return fileContent.length;
|
return fileContent.length;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var fullPath = path.resolve(this.outputPath || compilation.compiler.outputPath, this.options.assetsConstants);
|
||||||
|
var directory = path.dirname(fullPath);
|
||||||
|
|
||||||
|
mkdirp(directory, function (err) {
|
||||||
|
if (err) {
|
||||||
|
//return callback(err);
|
||||||
|
}
|
||||||
|
// Write to disk
|
||||||
|
fs.writeFile(fullPath, fileContent, function (err) {
|
||||||
|
if (err) {
|
||||||
|
//return callback(err);
|
||||||
|
}
|
||||||
|
//callback(null);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
};
|
};
|
||||||
|
13
package-lock.json
generated
13
package-lock.json
generated
@ -176,6 +176,19 @@
|
|||||||
"resolved": "https://registry.npmjs.org/lodash.some/-/lodash.some-4.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/lodash.some/-/lodash.some-4.6.0.tgz",
|
||||||
"integrity": "sha1-G7nzFO9ri63tE7VJFpsqlF62jk0="
|
"integrity": "sha1-G7nzFO9ri63tE7VJFpsqlF62jk0="
|
||||||
},
|
},
|
||||||
|
"minimist": {
|
||||||
|
"version": "0.0.8",
|
||||||
|
"resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||||
|
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
|
||||||
|
},
|
||||||
|
"mkdirp": {
|
||||||
|
"version": "0.5.1",
|
||||||
|
"resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||||
|
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
||||||
|
"requires": {
|
||||||
|
"minimist": "0.0.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nth-check": {
|
"nth-check": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz",
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
"author": "Philipp Dieter <philipp@glanzstueck.agency>",
|
"author": "Philipp Dieter <philipp@glanzstueck.agency>",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cheerio": "^0.22.0"
|
"cheerio": "^0.22.0",
|
||||||
|
"mkdirp": "^0.5.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user