Vue-cli: More options for baseUrl and outputDir settings in vue.config.js

Created on 18 Jun 2018  路  6Comments  路  Source: vuejs/vue-cli

What problem does this feature solve?

allowing absolute url's and setting output file name

What does the proposed API look like?

from:

module.exports = {
  baseUrl: process.env.NODE_ENV === 'production'
    ? '/'
    : '/dist/',

  // where to output built files
  outputDir: 'dist'
}

to:

module.exports = {
  baseUrl: process.env.NODE_ENV === 'production'
    ? '/'
    : 'https://www.example.com.test:8080/dist/',

  // where to output built files
  output: {
    directory: 'dist',
    filename: 'not-app.js' // allow access to [hash]?
  }
}

All 6 comments

If you need to adjust filename just use webpack configurations.

If you need to adjust filename just use webpack configurations.

@yyx990803 I'm not following your recommendation. I have a similar need and am getting outputDir is empty on build.

Are you suggesting to use vue > inspect to eject and edit that way?

@briancampo i ended up editing config passed from configureWebpack in vue.config.js.

BLUF: could this be a RC3 (using RC3 here as well) issue as in #1496 comment this morning

@Akryum and @taivu, that is what I thought but am running into avoid modifying output directly error with the below. Also tried editing the config.plugins["VueLoaderPlugin"] with no luck either

     config.output.publicPath =
      process.env.NODE_ENV === "production"
        ? process.env.VAR1
          ? process.env.VAR2
          : "/main/"
        : "/";

    config.output.path =
      process.env.NODE_ENV === "production"
        ? process.env.VAR1
          ? process.env.VAR3
          : "/public/"
        : "/";

    config.output.filename = process.env.VAR4;

@taivu Sorry to be so dense; could you post what you ended up with

@briancampo This is what I ended up with for my needs.

module.exports = {
  configureWebpack: (config) => {
    config.output.filename = 'myApp.js'
    config.output.chunkFilename = '[name]'
    process.env.NODE_ENV === 'production'
      ? config.optimization.splitChunks.cacheGroups.vendors.name = 'vendors'
      : console.log(config) // dev does not have `optimization.splitChunks`
  },
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

OmgImAlexis picture OmgImAlexis  路  3Comments

CodeApePro picture CodeApePro  路  3Comments

miyamoto-san picture miyamoto-san  路  3Comments

brandon93s picture brandon93s  路  3Comments

eladcandroid picture eladcandroid  路  3Comments