Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow generation of lot of pages #713

Closed
davidecampello opened this issue Jun 21, 2017 · 4 comments
Closed

Slow generation of lot of pages #713

davidecampello opened this issue Jun 21, 2017 · 4 comments

Comments

@davidecampello
Copy link

Hi, i'm using webpack+html-webpack-plugin to build a static website based on 2 .ejs template that should create a lot of pages.
To do this i have a configuration file like this:

module.exports = {
    entry: {
        vendorsAngular: path.resolve(__dirname, '../www/vendorsAngular.js'),
        vendors: path.resolve(__dirname, '../www/vendors.js'),
        app: path.resolve(__dirname, '../www/main.js'),
        appAngular: path.resolve(__dirname, '../www/mainAngular.js'),
    },
    output: {
        path: path.resolve(__dirname, '../build'),
        filename: '[name].bundle.js'
    },
    resolve: {
        modules: ['../www/lib', '../node_modules'],
        extensions: ['.js'],
        alias: {
            'jquery': 'jquery/src/jquery',
        }
    },
    module: {
        loaders: [
            {
                test: /\.css$/,
                loader: 'style-loader!css-loader'
            },
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            title: 'title1',
            template: path.resolve(__dirname, '../www/index.ejs'),
            filename: addPath('index.html'),
            excludeChunks: ['vendorsAngular', 'appAngular']
        }),
        new HtmlWebpackPlugin({
            title: 'page 1',
            template: path.resolve(__dirname, '../www/page.ejs'),
            filename: addPath('page.html'),
            excludeChunks: ['vendorsAngular', 'appAngular']
        }),
    ]
};

var titles = ['title2', 'title3' ... 'title1000'];
var createOtherPages = function() {
    titles.forEach(function(title) {
        module.exports.plugins.unshift(new HtmlWebpackPlugin({
            title: title,
            template: path.resolve(__dirname, '../www/index.ejs'),
            filename: title + '.html',
            excludeChunks: ['vendorsAngular', 'appAngular']
        }));
    });
};
createOtherPages();

The two questions are:
Is this the best approach to acheive what i want?
Webpack build is very slow, and fail because there is no memory enought. Do you have any suggestions to improve the performance beside to increase npm memory with --max_old_space_size npm param?

Thanks in advance.
Davide

@mastilver
Copy link
Collaborator

Uhm, for your use case I would probably use https://github.com/danethurber/webpack-manifest-plugin and another build tool like gulp that would read the manifest.json to output your desired html files

@scinos
Copy link
Contributor

scinos commented Jun 29, 2017

This should get better with #723

@jantimon
Copy link
Owner

Released: 2.30.0

@lock
Copy link

lock bot commented May 31, 2018

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants