Split common vendor javascript into chunks

This commit is contained in:
Yukai Huang 2016-10-11 12:30:30 +08:00
parent 7086a8c5e7
commit 9c8752d452
8 changed files with 20 additions and 16 deletions

View File

@ -120,6 +120,8 @@
"babel-loader": "^6.2.5",
"bower-webpack-plugin": "^0.1.9",
"css-loader": "^0.25.0",
"exports-loader": "^0.6.3",
"expose-loader": "^0.7.1",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"imports-loader": "^0.6.5",

View File

@ -5,14 +5,9 @@ require('jquery-ui/ui/widgets/controlgroup');
require('jquery-ui/ui/widgets/autocomplete');
/* jquery and jquery plugins */
require('jquery');
require('jquery-textcomplete');
require('jquery-mousewheel');
require('jquery-scrollspy/jquery-scrollspy');
require('../vendor/showup/showup');
/* bootstrap */
require('bootstrap');
require('bootstrap/dist/css/bootstrap.css');
require('prismjs/themes/prism.css');

View File

@ -5,10 +5,6 @@ require('jquery-ui/ui/widgets/controlgroup');
require('jquery-ui/ui/widgets/autocomplete');
/* jquery and jquery plugins */
require('jquery');
require('jquery-textcomplete');
require('jquery-mousewheel');
require('jquery-scrollspy/jquery-scrollspy');
require('../vendor/showup/showup');
/* bootstrap */

View File

@ -23,7 +23,7 @@
<% } %>
<script src="<%- url %>/vendor/Idle.Js/build/idle.min.js" defer></script>
<script src="<%- url %>/vendor/lz-string/libs/lz-string.min.js" defer></script>
<script src="<%- url %>/vendor/jquery/dist/jquery.min.js" defer></script>
<script src="<%- url %>/build/vendor.bundle.js" defer></script>
<!--codemirror-->
<script src="<%- url %>/vendor/codemirror/codemirror.min.js" defer></script>
<script src="<%- url %>/vendor/inlineAttachment/inline-attachment.js" defer></script>

View File

@ -193,9 +193,8 @@
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment-with-locales.min.js" defer></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/js-url/2.3.0/url.min.js" defer></script>
<% } else { %>
<script src="<%- url %>/vendor/jquery/dist/jquery.min.js" defer></script>
<script src="<%- url %>/build/vendor.bundle.js" defer></script>
<script src="<%- url %>/vendor/velocity/velocity.min.js" defer></script>
<script src="<%- url %>/vendor/bootstrap/dist/js/bootstrap.min.js" defer></script>
<script src="<%- url %>/vendor/select2/select2.min.js" defer></script>
<script src="<%- url %>/vendor/moment/min/moment-with-locales.min.js" defer></script>
<script src="<%- url %>/vendor/js-url/url.min.js" defer></script>

View File

@ -90,7 +90,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment-with-locales.min.js" defer></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/6.0.0/mermaid.min.js" defer></script>
<% } else { %>
<script src="<%- url %>/vendor/jquery/dist/jquery.min.js"></script>
<script src="<%- url %>/build/vendor.bundle.js" defer></script>
<script src="<%- url %>/vendor/js-yaml/dist/js-yaml.min.js" defer></script>
<script type="text/javascript" src="<%- url %>/vendor/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML" defer></script>
<script src="<%- url %>/vendor/moment/min/moment-with-locales.js" defer></script>

View File

@ -87,7 +87,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment-with-locales.min.js" defer></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/6.0.0/mermaid.min.js" defer></script>
<% } else { %>
<script src="<%- url %>/vendor/jquery/dist/jquery.min.js"></script>
<script src="<%- url %>/build/vendor.bundle.js" defer></script>
<script src="<%- url %>/vendor/reveal.js/lib/js/head.min.js"></script>
<script src="<%- url %>/vendor/reveal.js/js/reveal.js"></script>
<script src="<%- url %>/vendor/velocity/velocity.min.js" defer></script>

View File

@ -17,14 +17,26 @@ module.exports = {
new webpack.DefinePlugin({
"require.specified": "require.resolve"
}),
new ExtractTextPlugin("[name].css")
new ExtractTextPlugin("[name].css"),
new webpack.optimize.CommonsChunkPlugin({
name: "vendor",
filename: "vendor.bundle.js",
minChunks: Infinity,
})
],
entry: {
index: path.join(__dirname, 'public/js/index.js'),
public: path.join(__dirname, 'public/js/public.js'),
slide: path.join(__dirname, 'public/js/slide.js'),
locale: path.join(__dirname, 'public/js/locale.js')
locale: path.join(__dirname, 'public/js/locale.js'),
vendor: [
"expose?$!expose?jQuery!jquery",
"jquery-textcomplete",
"jquery-mousewheel",
"jquery-scrollspy/jquery-scrollspy",
"bootstrap"
]
},
output: {