Skip to content

Instantly share code, notes, and snippets.

@michael-wolfenden
Created September 14, 2018 03:13
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 michael-wolfenden/fa2c9dcfbf74d3a0e486fa964b959c2b to your computer and use it in GitHub Desktop.
Save michael-wolfenden/fa2c9dcfbf74d3a0e486fa964b959c2b to your computer and use it in GitHub Desktop.
Webpack issue - splitChunks alternative for CommonsChunkPlugin
// common modules used on every page
import axios from 'axios'
import Vue from 'vue'
// common css used on every page
import './shared.css'
// some global initialization
alert('common')
<!--
This page should trigger the common alert and the pageA alert
-->
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="shared.css" />
</head>
<body>
<script src="shared.js"></script>
<script src="pageA.js"></script>
</body>
</html>
import axios from 'axios'
import Vue from 'vue'
// module only used on this page
import moment from 'moment'
alert('pageA')
module.exports = {
entry: {
common: './common',
pageA: './pageA',
/* a bunch more pages
pageB: './pageB',
pageC: './pageC',
*/
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: ['common'],
minChunks: Infinity,
}),
],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment