bugfix for emit in manifest, add check parameter for svg

main v0.5.2
HerrHase 1 month ago
parent 00ba81570e
commit 0e3461afa1

@ -101,7 +101,7 @@ module.exports = function tinyComponentsWebpack(files, options = {}) {
} }
// adding svg src // adding svg src
if (defaults.svg.src) { if (defaults.svg && defaults.svg.src) {
config.plugins.push(new SvgSpritemapPlugin(defaults.svg.src, { config.plugins.push(new SvgSpritemapPlugin(defaults.svg.src, {
output: { output: {
filename: 'symbol-defs.svg', filename: 'symbol-defs.svg',

@ -49,7 +49,12 @@ class Manifest {
Object.keys(files).forEach((key) => { Object.keys(files).forEach((key) => {
files[key].forEach((file) => { files[key].forEach((file) => {
this._results[stats.publicPath + file] = stats.publicPath + file + '?version=' + this._hash(file, stats.outputPath)
const filePath = stats.outputPath + '/' + file
if (fs.existsSync(filePath)) {
this._results[stats.publicPath + file] = stats.publicPath + file + '?version=' + this._hash(filePath)
}
}) })
}) })
@ -64,9 +69,9 @@ class Manifest {
* @return {string} * @return {string}
* *
*/ */
_hash(file, outputPath) { _hash(filePath) {
const data = fs.readFileSync(outputPath + '/' + file, 'utf8') const data = fs.readFileSync(filePath, 'utf8')
const hash = crypto const hash = crypto
.createHash('md5') .createHash('md5')
.update(data) .update(data)

@ -1,6 +1,6 @@
{ {
"name": "@tiny-components/webpack", "name": "@tiny-components/webpack",
"version": "0.5.1", "version": "0.5.2",
"description": "Webpack Wrapper", "description": "Webpack Wrapper",
"repository": { "repository": {
"type": "git", "type": "git",

@ -31,7 +31,7 @@ class ManifestPlugin {
// create manifest object // create manifest object
const manifest = new Manifest(this._filename, this._context) const manifest = new Manifest(this._filename, this._context)
compiler.hooks.emit.tapAsync(pluginName, (compilation, callback) => { compiler.hooks.afterEmit.tapAsync(pluginName, (compilation, callback) => {
const stats = compilation.getStats().toJson() const stats = compilation.getStats().toJson()
manifest.run(stats) manifest.run(stats)

Loading…
Cancel
Save