Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Webpack code splitting configuration example
module.exports = {
entry: {
main: './src/app.js',
},
output: {
// `filename` provides a template for naming your bundles (remember to use `[name]`)
filename: '[name].bundle.js',
// `chunkFilename` provides a template for naming code-split bundles (optional)
chunkFilename: '[name].bundle.js',
// `path` is the folder where Webpack will place your bundles
path: './dist',
// `publicPath` is where Webpack will load your bundles from (optional)
publicPath: 'dist/'
}
};
@jovanliuc

This comment has been minimized.

Copy link

@jovanliuc jovanliuc commented Jan 30, 2018

and just kick-off of an extremely simple webpack-config demo.

@titanve

This comment has been minimized.

Copy link

@titanve titanve commented Dec 11, 2018

Hello Dan!

Do you have a reactjs example for code splitting with webpack 4 ?

I've tried so many things I've found online but I cannot get webpack to split my code.

Thanks!

@janmauler

This comment has been minimized.

Copy link

@janmauler janmauler commented Jan 9, 2019

If concerned about browser caching of bundles:

   filename: '[contenthash].bundle.js',
   chunkFilename: '[contenthash].bundle.js'
@niteeshb7

This comment has been minimized.

Copy link

@niteeshb7 niteeshb7 commented May 6, 2019

Thank you

@Bubbfish

This comment has been minimized.

Copy link

@Bubbfish Bubbfish commented Dec 6, 2019

thanks

@jvkiran

This comment has been minimized.

Copy link

@jvkiran jvkiran commented Jan 24, 2020

Thanks

@jobyjoseph

This comment has been minimized.

Copy link

@jobyjoseph jobyjoseph commented May 25, 2020

Thank you. my [name] is coming as 1, 0 ... as chunk name. I am using import(). can we have specific names for the chunk file names?

@obedparla

This comment has been minimized.

Copy link

@obedparla obedparla commented May 28, 2020

@xgqfrms

This comment has been minimized.

Copy link

@xgqfrms xgqfrms commented Oct 15, 2020

code splitting & dynamic import

chunkFilename

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.