Created
September 14, 2018 03:13
-
-
Save michael-wolfenden/fa2c9dcfbf74d3a0e486fa964b959c2b to your computer and use it in GitHub Desktop.
Webpack issue - splitChunks alternative for CommonsChunkPlugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios' | |
import Vue from 'vue' | |
// module only used on this page | |
import moment from 'moment' | |
alert('pageA') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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