Wednesday, 31 May 2017

Webpack Multiple Entry giving random files (0.name.js, 1.name.js and so on)

Setting up an existing project to use webpack. Currently using webjars. There are multiple entry points.

I am expecting the below code to give me three files however I am getting extra files with no names i.e 0.bundle.js, 1.bundle.js.

Page.js and blog.js both reference quite a few modules, some of which are the same, however in the setup below webpack shouldn't be trying to merge any common modules.

const webpack = require('webpack');
const path = require('path');

const config = {
    entry: {
        "marketing": ['app/assets/javascripts/marketing/page.js'],
        "blog": ['app/assets/javascripts/marketing/blog.js'],
        "vendor": ['vue', 'vue-router', 'axios', 'etc'] 
    },
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: '[name].bundle.js'
    },
    resolve: {
        modules: [
            path.resolve('./'),
            path.resolve('./node_modules'),
        ]
    },
    module: {
        rules: [
            {test: /\.(js|jsx)$/, use: 'babel-loader'}
        ]
    },
};

module.exports = config;

Why am I getting these extra files?

Thanks



via Ralph King

No comments:

Post a Comment