From efd62bd1ca5550080ccf1254ecb95c5cb6afd983 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sat, 26 Nov 2016 23:24:59 +0800 Subject: [PATCH] Optimize slide page resource packing and load orders, fix possible wrong chunks orders and font awesome version --- public/js/slide.js | 1 - public/views/html.hbs | 2 +- public/views/slide.ejs | 49 +++++++++++++++--------------------------- webpackBaseConfig.js | 49 +++++++++++++++++++++++++++++++++++++++--- 4 files changed, 64 insertions(+), 37 deletions(-) diff --git a/public/js/slide.js b/public/js/slide.js index 8d45219..fa4adcb 100644 --- a/public/js/slide.js +++ b/public/js/slide.js @@ -1,6 +1,5 @@ require('../css/extra.css'); require('../css/site.css'); -require('../css/slide.css'); var extraModule = require('./extra'); var md = extraModule.md; diff --git a/public/views/html.hbs b/public/views/html.hbs index 2e45707..46b1b92 100644 --- a/public/views/html.hbs +++ b/public/views/html.hbs @@ -16,7 +16,7 @@ - + diff --git a/public/views/slide.ejs b/public/views/slide.ejs index cd3be9a..bfc5edd 100644 --- a/public/views/slide.ejs +++ b/public/views/slide.ejs @@ -15,31 +15,23 @@ <% if(useCDN) { %> - + - + + <%- include build/slide-header %> <% } else { %> - - - - + + <%- include build/slide-pack-header %> <% } %> - + - - - - - - - - - <%- include build/slide-header %> + + + + + - <% } else { %> - - - - - - - - - - <% } %> - - - - - + <%- include build/slide-scripts %> + <% } else { %> + + + <%- include build/slide-pack-scripts %> + <% } %> diff --git a/webpackBaseConfig.js b/webpackBaseConfig.js index ba5db4b..6c83f82 100644 --- a/webpackBaseConfig.js +++ b/webpackBaseConfig.js @@ -16,6 +16,7 @@ module.exports = { "moment": "moment", "Handlebars": "handlebars" }), + new webpack.optimize.OccurrenceOrderPlugin(true), new webpack.optimize.CommonsChunkPlugin({ names: ["cover", "index", "pretty", "slide", "vendor"], children: true, @@ -95,14 +96,21 @@ module.exports = { filename: path.join(__dirname, 'public/views/build/pretty-pack-scripts.ejs'), inject: false }), + new HtmlWebpackPlugin({ template: 'public/views/includes/header.ejs', - chunks: ['vendor', 'slide'], + chunks: ['font', 'slide-styles', 'slide'], filename: path.join(__dirname, 'public/views/build/slide-header.ejs'), inject: false }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/header.ejs', + chunks: ['font-pack', 'slide-styles-pack', 'slide-styles', 'slide'], + filename: path.join(__dirname, 'public/views/build/slide-pack-header.ejs'), + inject: false + }), new HtmlWebpackPlugin({ template: 'public/views/includes/scripts.ejs', - chunks: ['vendor', 'slide'], + chunks: ['slide'], filename: path.join(__dirname, 'public/views/build/slide-scripts.ejs'), inject: false }), @@ -133,7 +141,6 @@ module.exports = { ], entry: { - slide: path.join(__dirname, 'public/js/slide.js'), font: path.join(__dirname, 'public/css/google-font.css'), "font-pack": path.join(__dirname, 'public/css/font.css'), common: [ @@ -266,6 +273,40 @@ module.exports = { path.join(__dirname, 'public/js/reveal-markdown.js'), path.join(__dirname, 'public/js/pretty.js') ], + slide: [ + "expose?filterXSS!xss", + "flowchart.js", + "js-sequence-diagrams", + path.join(__dirname, 'public/js/reveal-markdown.js'), + path.join(__dirname, 'public/js/slide.js') + ], + "slide-styles": [ + path.join(__dirname, 'public/css/github-extract.css'), + path.join(__dirname, 'public/css/mermaid.css'), + path.join(__dirname, 'public/css/markdown.css') + ], + "slide-styles-pack": [ + path.join(__dirname, 'node_modules/font-awesome/css/font-awesome.min.css'), + path.join(__dirname, 'node_modules/ionicons/css/ionicons.min.css'), + path.join(__dirname, 'node_modules/octicons/octicons/octicons.css'), + path.join(__dirname, 'public/vendor/bootstrap/tooltip.min.css') + ], + "slide-pack": [ + "expose?jsyaml!js-yaml", + "script!mermaid", + "expose?moment!moment", + "script!handlebars", + "expose?hljs!highlight.js", + "expose?emojify!emojify.js", + "expose?filterXSS!xss", + "script!gist-embed", + "flowchart.js", + "js-sequence-diagrams", + "expose?Viz!viz.js", + "headjs", + "expose?Reveal!reveal.js", + path.join(__dirname, 'public/js/reveal-markdown.js'), + path.join(__dirname, 'public/js/slide.js') ] }, @@ -293,6 +334,8 @@ module.exports = { handlebars: path.join(__dirname, 'node_modules/handlebars/dist/handlebars.min.js'), "jquery-ui-resizable": path.join(__dirname, 'public/vendor/jquery-ui/jquery-ui.min.js'), "gist-embed": path.join(__dirname, 'node_modules/gist-embed/gist-embed.min.js'), + "bootstrap-tooltip": path.join(__dirname, 'public/vendor/bootstrap/tooltip.min.js'), + "headjs": path.join(__dirname, 'node_modules/reveal.js/lib/js/head.min.js') } },