How to execute custom functions after vue-cli3.0 has been packaged

I"m using Vue-cli 3.x + scaffolding. After the completion of the project development, I hope to be able to execute my own custom function after the implementation of npm run build to operate the packaged files, compress and automatically upload and deploy to the test environment. If you are using a custom developed plug-in, how to ensure that the plug-in function is executed after packaging and generation.

Jun.01,2022

found a solution by writing a custom development plug-in that has configureWebpack this attribute
ide/webpack.html-sharp%E7%AE%80%E5%8D%95%E7%9A%84%E9%85%8D%E7%BD%AE%E6%96%B9%E5%BC%8F" rel=" nofollow noreferrer "Vue-cli3.X webpack related

in the objects exported from the vue.config.js file.
configureWebpack: config => {
    if (process.env.NODE_ENV === 'production') {
      // ...
      config.plugins.push({
        apply: (compiler) => {
          compiler.hooks.done.tap(pluginName, compilation => {
            // do something when webpack compilation done
          });
        }
      })
    } else {
      // ...
    }

this is the hook function provided by webpack. More hook functions can be found in webpack's compiler hook function .

Menu