1 year ago

#366719

test-img

Frallen

Webpack generate multiple entry

I need to configure the webpack so that it compile scripts and styles in the development folder, each folder has its own name. It should transfer the compiled files to another directory with the same folder names.

I also need to copy global styles and scripts above these folders.

How to implement this? I just can't figure out how to do it

I don't need to copy, I need to сompile to another directory with the same folder names for each component

Now i have this.

const PATHS = {
    source: path.join(__dirname, 'src'),
    build: path.join(__dirname, '../web/dist'),
};

const common = merge([
    {
        entry: {
            'script': PATHS.source + '/index.js'
        },
        output: {
            path: PATHS.build,
            filename: './[name].js',
        },
        module: {},
       
    },
 //   fonts(),
    images(),
    babel()
]);

module.exports = (env, argv) => {
    let config =  common;

    if (argv.mode === 'development') {
        config = merge([
            config,
            devCSS(),
            devserver(),
        ]);
    }

    if (argv.mode === 'production') {
        config = merge([
            config,
            prodCSS()
        ]);
        if (!env) {
            config = merge([
                {
                    devtool: 'source-map',
                  /*  plugins: [
                        new CleanWebpackPlugin()
                    ],*/
                },
                config,
              //  favicon(PATHS)
            ]);
        } else if (env.update) {
            config = merge([
                config,
                {
                    watch: true,
                    watchOptions: {
                        aggregateTimeout: 300,
                        poll: 1000,
                        ignored: ['src/fonts', 'node_modules']
                    }
                }
            ]);
        }
    }
    return config;
};

enter image description here

javascript

webpack

webpack-4

0 Answers

Your Answer

Accepted video resources