简体   繁体   中英

Rollup watch only one config in exported array

does somebody know, how I can only watch one config of an array, witch I have exported, by typing rollup -c -w and by typing only rollup -c it will compile it to 4 different versions? That means, if I will watch the js files, it compiles only one config for me eg the cjs one. I have already tried, to set watch to false, but it doesn't work and I think two different files are to stupid. Have somebody an idea to to this? This is my actual config:

// rollup.config.js
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';

import pkg from './package.json';

export default [
    {
        input: 'src/main.js',
        output: {
            file: pkg.main,
            format: 'cjs',
        },
        watch: {
            exclude: ['node_modules/'],
        },
        plugins: [
            resolve(),
            commonjs(),
            babel({
                exclude: 'node_modules/**',
                babelrc: false,
                presets: [
                    [
                        '@babel/env',
                        {
                            modules: false,
                            useBuiltIns: 'usage',
                            targets: 'maintained node versions',
                            corejs: '3.6.5',
                        },
                    ],
                ],
            }),
        ],
    },
    {
        input: 'src/main.js',
        output: {
            file: pkg.browser,
            format: 'umd',
            name: 'eatFruit',
        },
        plugins: [
            resolve(),
            commonjs(),
            babel({
                exclude: 'node_modules/**',
            }),
        ],
    },
    {
        input: 'src/main.js',
        output: {
            file: pkg.browser.replace(/\.js$/, '.min.js'),
            format: 'umd',
            name: 'eatFruit',
        },
        plugins: [
            resolve(),
            commonjs(),
            babel({
                exclude: 'node_modules/**',
            }),
            terser(),
        ],
    },
    {
        input: 'src/main.js',
        output: {
            file: pkg.module,
            format: 'es',
        },
        plugins: [
            resolve(),
            commonjs(),
            babel({
                exclude: 'node_modules/**',
            }),
        ],
    },
];

Well, this function does not exist yet but I have now started an issue. https://github.com/rollup/rollup/issues/3607

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM