How can I create two separate bundles with vue-cli 3?

后端 未结 4 908
星月不相逢
星月不相逢 2021-01-30 21:15

I want to build two separate vue apps that will be served on two different routes in an express application: a ‘public’ vue app and an ‘admin’ vue app. These two apps have their

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-30 21:40

    It is also possible to have multiple vue.config.js configs and switch them over using the VUE_CLI_SERVICE_CONFIG_PATH environment variable.

    For example, we can have a default vue.config.js and an additional vue.public.config.js and run the build like this:

    # Build using vue.config.public.js
    # Note: using real path here, it didn't work with relative path
    CONF=`realpath vue.config.public.js`
    VUE_CLI_SERVICE_CONFIG_PATH=$CONF npm run build
    
    # Build using default vue.config.js
    npm run build
    

    Where npm run build is defined in package.json as vue-cli-service build:

    "scripts": {
        "build": "vue-cli-service build"
    }
    

    Note: I didn't find any mention on VUE_CLI_SERVICE_CONFIG_PATH in the documentation, found it looking at the source code.

提交回复
热议问题