Added a webpack clean plugin to the demo and emiting assets via build info
parent
c3b1a70f56
commit
9e41c79f55
|
@ -1,5 +1,6 @@
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import {Configuration} from "webpack";
|
import {Configuration} from "webpack";
|
||||||
|
import {CleanWebpackPlugin} from "clean-webpack-plugin";
|
||||||
import * as SpriteGenerator from "../plugin";
|
import * as SpriteGenerator from "../plugin";
|
||||||
import * as HtmlWebpackPlugin from "html-webpack-plugin";
|
import * as HtmlWebpackPlugin from "html-webpack-plugin";
|
||||||
|
|
||||||
|
@ -8,6 +9,7 @@ export = {
|
||||||
target: "web",
|
target: "web",
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
|
new CleanWebpackPlugin(),
|
||||||
new SpriteGenerator.Plugin({
|
new SpriteGenerator.Plugin({
|
||||||
dtsOutputFolder: path.join(__dirname, "app"),
|
dtsOutputFolder: path.join(__dirname, "app"),
|
||||||
configurations: {
|
configurations: {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "webpack-svg-sprite-generator",
|
"name": "webpack-svg-sprite-generator",
|
||||||
"version": "1.0.12",
|
"version": "1.0.13",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "plugin.js",
|
"main": "plugin.js",
|
||||||
"types": "ts/index.d.ts",
|
"types": "ts/index.d.ts",
|
||||||
|
|
|
@ -69,7 +69,10 @@ class SvgSpriteModule extends Module {
|
||||||
async: false,
|
async: false,
|
||||||
exportsType: undefined
|
exportsType: undefined
|
||||||
};
|
};
|
||||||
this.buildInfo = {};
|
this.buildInfo = {
|
||||||
|
cacheable: true,
|
||||||
|
assets: {}
|
||||||
|
};
|
||||||
|
|
||||||
if(this.spriteAssetName) {
|
if(this.spriteAssetName) {
|
||||||
delete compilation.assets[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.spriteAssetName = "sprite-" + sha1(this.spriteSvg).substr(-20) + ".svg";
|
||||||
this.spriteAssetUrl = (compilation.options.output.publicPath || "") + this.spriteAssetName;
|
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 = "";
|
this.spriteCss = "";
|
||||||
for(const cssOption of this.config.cssOptions) {
|
for(const cssOption of this.config.cssOptions) {
|
||||||
|
|
Loading…
Reference in New Issue