1.0.2 • Published 2 years ago

@jswork/file-callback-webpack-plugin v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

file-callback-webpack-plugin

File callback webpack plugin.

version license size download

installation

npm install @jswork/file-callback-webpack-plugin

usage

const { defineConfig } = require('@vue/cli-service');
const FileCbPlugin = require('@jswork/file-callback-webpack-plugin');
const { envname } = require('@jswork/ci-kits');
const ENVS = require('./.env-cmdrc');
const currentEnvs = ENVS[envname()];

// usage
const manifestReplace = new FileCbPlugin({
  path: 'src/manifest.json',
  callback: (content) => {
    nx.set(
      content,
      'mp-weixin.appid',
      JSON.parse(currentEnvs['VUE_APP_APP_ID'])
    );
    return content;
  }
});

module.exports = defineConfig({
  configureWebpack: (config) => {
    const plugins = config.plugins;
    config.devtool = 'source-map';
    config.plugins = [...plugins, manifestReplace];
  }
});

license

Code released under the MIT license.

1.0.2

2 years ago

1.0.1

2 years ago