Vue-cli: The possibility of having many input and output files

Created on 15 Oct 2018  路  5Comments  路  Source: vuejs/vue-cli

What problem does this feature solve?

The ability to have multiple input and output files in vue-cli-service build --target lib mode would be very useful. I tried to configure the Webpack in the vue.config.js file to pass many input files and generate many output files, unfortunately without success. It looks like it is not possible. I have a simple usage example, I want to build extensions in separate files.

What does the proposed API look like?

module.exports = {
    configureWebpack: config => {
        config.output = {
            filename: '[name].js',
            path: resolve('/dist'),
            library: '[name]',
            libraryTarget: 'umd'
        }

        config.entry = {
            'components/a': 'src/a.js',
            'directives/b': 'src/b.js',
            'directives/c': 'src/c.js'
            // etc
        }
    }
}

Most helpful comment

you can use execa, for example. We use it in vue-cli to run command line arguments from node as well.

All 5 comments

What's wrong with running build several times?

I guess there's nothing wrong, I just have a more specific case. I collect files and generate entries dynamically, currently I have about ~35 such files and this number is growing. It is not practical to write them manually. I have not found in the documentation how I could launch the process of building vue-cli-service inside a file (instead of a command) and give it configuration. Do you have an example?

you can use execa, for example. We use it in vue-cli to run command line arguments from node as well.

Thank you, it looks like it works. One more thing, is it possible to generate one file instead of three? Currently, files with .common.js,.umd.js and .umd.min.js are generated. All I need is one in the commonJS format with the extension .js. I can not find any mention in the documentation.

// EDIT
I just reviewed the cli-service code and I see that there is no option to disable it at this moment. Maybe it would be a good idea to add an option to disable the generation of these three formats in favor of one?

Maybe it would be a good idea to add an option to disable the generation of these three formats in favor of one?

See #2583

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Benzenes picture Benzenes  路  3Comments

CodeApePro picture CodeApePro  路  3Comments

Gonzalo2683 picture Gonzalo2683  路  3Comments

b-zee picture b-zee  路  3Comments

OmgImAlexis picture OmgImAlexis  路  3Comments