Skip to content

Instantly share code, notes, and snippets.

@r-i-c-h
Last active January 24, 2020 13:52
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 r-i-c-h/e04d7800e5e7da8b2867169aaa9877db to your computer and use it in GitHub Desktop.
Save r-i-c-h/e04d7800e5e7da8b2867169aaa9877db to your computer and use it in GitHub Desktop.
Webpack Code Splitting
/* orig https://gist.github.com/gaearon/ca6e803f5c604d37468b0091d9959269 */
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/'
},
module: {
rules: [
{
test: /\.(scss)$/,
use: [
{
// Adds CSS to the DOM by injecting a `<style>` tag
loader: 'style-loader'
},
{
// Interprets `@import` and `url()` like `import/require()` and will resolve themn
loader: 'css-loader'
},
{
// Loads a SASS/SCSS file and compiles it to CSS
loader: 'sass-loader'
}
]
}
]
};
};
// https://github.com/FullHuman/purgecss-webpack-plugin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment