Vector-Green / add-asset-plugin

Plugin that emits some assets at some webpack 5 compilations stages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add Asset Plugin for Webpack 5

emits assets at some compilations stages

npm i add-asset-plugin --save-dev yarn add add-asset-plugin --dev

Example

Vue 3 cli

//vue.config.js
const webpack = require("webpack");

const AddAssetPlugin = require("add-asset-plugin");
const addAssetPlugin = new AddAssetPlugin();

const { defineConfig } = require("@vue/cli-service");

module.exports = defineConfig({
  addAssetPlugin.addBeforeCompression("fileName", "fileContent"); //anywhere
  configureWebpack: (config) => {
    config.plugins.push(addAssetPlugin);
  },
});

React

//webpack.config.js
const webpack = require("webpack");

const AddAssetPlugin = require("add-asset-plugin");
const addAssetPlugin = new AddAssetPlugin();

module.exports = function () {
  return {
    mode: process.env.NODE_ENV,
    addAssetPlugin.addBeforeCompression("fileName", "fileContent"); //anywhere
    plugins: [addAssetPlugin],
  };
};

About

Plugin that emits some assets at some webpack 5 compilations stages


Languages

Language:JavaScript 100.0%