Skip to content

Instantly share code, notes, and snippets.

@bojan88
Created May 7, 2021 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bojan88/9e3e608b1109decb86e400854144aac5 to your computer and use it in GitHub Desktop.
Save bojan88/9e3e608b1109decb86e400854144aac5 to your computer and use it in GitHub Desktop.
Chunk and template replacement in preact-cli build
if (env.production && !env.isServer) {
config.entry['public-bundle'] = path.resolve(__dirname, 'public-page.entry.js');
for (const { plugin: { options } } of helpers.getPluginsByName(config, 'HtmlWebpackPlugin')) {
if (options.url === '/account') {
options.chunks = ['bundle', 'polyfills'];
options.template = `!!ejs-loader?esModule=false!${path.resolve(__dirname, './src/app-template.ejs')}`;
} else {
options.chunks = ['public-bundle', 'polyfills'];
options.template = `!!ejs-loader?esModule=false!${path.resolve(__dirname, './src/public-template.ejs')}`;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment