From 9e41c79f55eb552a2739f0de959cf2e91a5f4a55 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sun, 9 Aug 2020 14:01:48 +0200 Subject: [PATCH] Added a webpack clean plugin to the demo and emiting assets via build info --- demo/webpack.config.ts | 2 ++ package.json | 2 +- plugin/plugin.ts | 7 +++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/demo/webpack.config.ts b/demo/webpack.config.ts index bcb0587..5033f0c 100644 --- a/demo/webpack.config.ts +++ b/demo/webpack.config.ts @@ -1,5 +1,6 @@ import * as path from "path"; import {Configuration} from "webpack"; +import {CleanWebpackPlugin} from "clean-webpack-plugin"; import * as SpriteGenerator from "../plugin"; import * as HtmlWebpackPlugin from "html-webpack-plugin"; @@ -8,6 +9,7 @@ export = { target: "web", plugins: [ + new CleanWebpackPlugin(), new SpriteGenerator.Plugin({ dtsOutputFolder: path.join(__dirname, "app"), configurations: { diff --git a/package.json b/package.json index 887f786..03ebae5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webpack-svg-sprite-generator", - "version": "1.0.12", + "version": "1.0.13", "description": "", "main": "plugin.js", "types": "ts/index.d.ts", diff --git a/plugin/plugin.ts b/plugin/plugin.ts index 5a167c5..4cdacfc 100644 --- a/plugin/plugin.ts +++ b/plugin/plugin.ts @@ -69,7 +69,10 @@ class SvgSpriteModule extends Module { async: false, exportsType: undefined }; - this.buildInfo = {}; + this.buildInfo = { + cacheable: true, + assets: {} + }; if(this.spriteAssetName) { delete compilation.assets[this.spriteAssetName]; @@ -83,7 +86,7 @@ class SvgSpriteModule extends Module { this.spriteAssetName = "sprite-" + sha1(this.spriteSvg).substr(-20) + ".svg"; this.spriteAssetUrl = (compilation.options.output.publicPath || "") + this.spriteAssetName; - compilation.assets[this.spriteAssetName] = new RawSource(this.spriteSvg); + this.buildInfo.assets[this.spriteAssetName] = new RawSource(this.spriteSvg); this.spriteCss = ""; for(const cssOption of this.config.cssOptions) {