bugfix for emit in manifest, add check parameter for svg

main v0.5.2
HerrHase 3 months ago
parent 00ba81570e
commit 0e3461afa1

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

@ -49,7 +49,12 @@ class Manifest {
Object.keys(files).forEach((key) => {
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}
*
*/
_hash(file, outputPath) {
_hash(filePath) {
const data = fs.readFileSync(outputPath + '/' + file, 'utf8')
const data = fs.readFileSync(filePath, 'utf8')
const hash = crypto
.createHash('md5')
.update(data)

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

@ -31,7 +31,7 @@ class ManifestPlugin {
// create manifest object
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()
manifest.run(stats)

Loading…
Cancel
Save