vue-cli icon indicating copy to clipboard operation
vue-cli copied to clipboard

The possibility of having many input and output files

Open hstaniszewski opened this issue 8 years ago • 5 comments

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
        }
    }
}

hstaniszewski avatar Oct 15 '18 18:10 hstaniszewski

What's wrong with running build several times?

LinusBorg avatar Oct 15 '18 19:10 LinusBorg

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?

hstaniszewski avatar Oct 16 '18 06:10 hstaniszewski

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

LinusBorg avatar Oct 16 '18 06:10 LinusBorg

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?

hstaniszewski avatar Oct 16 '18 09:10 hstaniszewski

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

LinusBorg avatar Oct 19 '18 07:10 LinusBorg