Vuejs Library CLI v3 Exclude

后端 未结 1 1819
逝去的感伤
逝去的感伤 2021-01-21 14:36

I am using vuejs CLI version 3 and am building my library using this target in the package.json

vue-cli-service build --report-json --target lib --name component         


        
相关标签:
1条回答
  • 2021-01-21 14:48

    The configureWebpack object goes in a vue.config.js file. Then, use a ternary on the NODE_ENV so the dependencies still get injected when you launch your application with npm run serve.

    See https://cli.vuejs.org/guide/webpack.html.

    const webpack = require("webpack");
    
    function getProdExternals() {
      return {
        axios: "axios",
        lodash: "lodash",
        jquery: "jQuery",
        vue: "Vue"
      };
    }
    
    module.exports = {
      configureWebpack: {
        externals: process.env.NODE_ENV === 'production' ?
          getProdExternals() : {}
      }
    }

    0 讨论(0)
提交回复
热议问题