From f9e7f482d307f89af8a4281a7bdb719297f07c21 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Tue, 11 Oct 2016 15:45:00 +0800 Subject: Setup webpack production config --- webpack.production.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 webpack.production.js (limited to 'webpack.production.js') diff --git a/webpack.production.js b/webpack.production.js new file mode 100644 index 00000000..f4125cec --- /dev/null +++ b/webpack.production.js @@ -0,0 +1,36 @@ +var baseConfig = require('./webpackBaseConfig'); +var webpack = require('webpack'); +var ExtractTextPlugin = require("extract-text-webpack-plugin"); + +module.exports = Object.assign({}, baseConfig, { + plugins: [ + new webpack.ProvidePlugin({ + '_': 'lodash', + Visibility: "visibilityjs", + Cookies: "js-cookie", + emojify: "emojify.js", + io: "socket.io-client", + key: "keymaster" + }), + new webpack.DefinePlugin({ + "require.specified": "require.resolve" + }), + new ExtractTextPlugin("[name].css"), + new webpack.optimize.CommonsChunkPlugin({ + name: "vendor", + filename: "vendor.bundle.js", + minChunks: Infinity, + }), + new webpack.DefinePlugin({ + 'process.env': { + 'NODE_ENV': JSON.stringify('production') + } + }), + new webpack.optimize.UglifyJsPlugin({ + compress: { + warnings: false + }, + sourceMap: false + }) + ] +}); -- cgit v1.3.1 From 56c5378939c6498d0440b3ed76a604523678073f Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Tue, 11 Oct 2016 17:15:06 +0800 Subject: Optimize viz.js async rendering through webpack chunk --- public/js/extra.js | 32 ++++++++++++++++++-------------- public/js/index.js | 6 ------ public/views/foot.ejs | 2 +- public/views/index.ejs | 2 +- public/views/pretty.ejs | 2 +- public/views/slide.ejs | 2 +- webpack.production.js | 9 +++++---- webpackBaseConfig.js | 18 ++++++++++-------- 8 files changed, 37 insertions(+), 36 deletions(-) (limited to 'webpack.production.js') diff --git a/public/js/extra.js b/public/js/extra.js index 329aa153..e133a810 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -288,21 +288,25 @@ function finishView(view) { } }); //graphviz - var graphvizs = view.find(".graphviz.raw").removeClass("raw"); - graphvizs.each(function (key, value) { - try { - var $value = $(value); - var $ele = $(value).parent().parent(); - - var graphviz = Viz($value.text()); - $value.html(graphviz); + require.ensure(["viz.js"], function(require) { + var Viz = require("viz.js"); + var graphvizs = view.find(".graphviz.raw").removeClass("raw"); + graphvizs.each(function (key, value) { + try { + var $value = $(value); + var $ele = $(value).parent().parent(); + + var graphviz = Viz($value.text()); + $value.html(graphviz); + + $ele.addClass('graphviz'); + $value.children().unwrap().unwrap(); + } catch (err) { + console.warn(err); + } + }); - $ele.addClass('graphviz'); - $value.children().unwrap().unwrap(); - } catch (err) { - console.warn(err); - } - }); + }) //mermaid var mermaids = view.find(".mermaid.raw").removeClass("raw"); mermaids.each(function (key, value) { diff --git a/public/js/index.js b/public/js/index.js index 4bce2ff0..2d3c2965 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1,9 +1,3 @@ -/* include jquery ui */ -require('jquery-ui/ui/widgets/resizable'); -require('jquery-ui/ui/widgets/tooltip'); -require('jquery-ui/ui/widgets/controlgroup'); -require('jquery-ui/ui/widgets/autocomplete'); - /* jquery and jquery plugins */ require('../vendor/showup/showup'); diff --git a/public/views/foot.ejs b/public/views/foot.ejs index 4a9b1756..adab9d15 100644 --- a/public/views/foot.ejs +++ b/public/views/foot.ejs @@ -21,7 +21,7 @@ <% } %> - + diff --git a/public/views/index.ejs b/public/views/index.ejs index c7bea341..c00623c6 100644 --- a/public/views/index.ejs +++ b/public/views/index.ejs @@ -185,7 +185,7 @@ - + <% if(useCDN) { %> diff --git a/public/views/pretty.ejs b/public/views/pretty.ejs index 6f13155a..4cfbdb04 100644 --- a/public/views/pretty.ejs +++ b/public/views/pretty.ejs @@ -90,7 +90,7 @@ <% } else { %> - + diff --git a/public/views/slide.ejs b/public/views/slide.ejs index b0c5ddbc..b3212f44 100644 --- a/public/views/slide.ejs +++ b/public/views/slide.ejs @@ -87,7 +87,7 @@ <% } else { %> - + diff --git a/webpack.production.js b/webpack.production.js index f4125cec..1c54ae38 100644 --- a/webpack.production.js +++ b/webpack.production.js @@ -17,10 +17,11 @@ module.exports = Object.assign({}, baseConfig, { }), new ExtractTextPlugin("[name].css"), new webpack.optimize.CommonsChunkPlugin({ - name: "vendor", - filename: "vendor.bundle.js", - minChunks: Infinity, - }), + name: ["vendor", "public", "slide", "locale"], + async: true, + filename: '[name].js', + minChunks: Infinity + }) new webpack.DefinePlugin({ 'process.env': { 'NODE_ENV': JSON.stringify('production') diff --git a/webpackBaseConfig.js b/webpackBaseConfig.js index 6d99381c..e2d58f4d 100644 --- a/webpackBaseConfig.js +++ b/webpackBaseConfig.js @@ -17,9 +17,10 @@ module.exports = { }), new ExtractTextPlugin("[name].css"), new webpack.optimize.CommonsChunkPlugin({ - name: "vendor", - filename: "vendor.bundle.js", - minChunks: Infinity, + name: ["vendor", "public", "slide", "locale"], + async: true, + filename: '[name].js', + minChunks: Infinity }) ], @@ -33,9 +34,12 @@ module.exports = { "jquery-textcomplete", "jquery-mousewheel", "jquery-scrollspy/jquery-scrollspy", + "jquery-ui/ui/widgets/resizable", + "jquery-ui/ui/widgets/tooltip", + "jquery-ui/ui/widgets/controlgroup", + "jquery-ui/ui/widgets/autocomplete", "expose?LZString!lz-string", "expose?filterXSS!xss", - "expose?Viz!viz.js", "js-url", "bootstrap" ] @@ -43,6 +47,7 @@ module.exports = { output: { path: path.join(__dirname, 'public/build'), + publicPath: '/build/', filename: '[name].js' }, @@ -51,10 +56,7 @@ module.exports = { path.resolve(__dirname, 'src'), path.resolve(__dirname, 'node_modules') ], - extensions: ["", ".js"], - alias: { - 'jquery-ui': 'jquery-ui/ui/widgets' - } + extensions: ["", ".js"] }, module: { -- cgit v1.3.1 From ddb953da0ca4dbbc5763e284f5cc7f974589434f Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Tue, 11 Oct 2016 18:59:05 +0800 Subject: Fix webpack production config --- webpack.production.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webpack.production.js') diff --git a/webpack.production.js b/webpack.production.js index 1c54ae38..c954bd43 100644 --- a/webpack.production.js +++ b/webpack.production.js @@ -21,7 +21,7 @@ module.exports = Object.assign({}, baseConfig, { async: true, filename: '[name].js', minChunks: Infinity - }) + }), new webpack.DefinePlugin({ 'process.env': { 'NODE_ENV': JSON.stringify('production') -- cgit v1.3.1 From 05d5a44d99ac08a4e3f9cd54702f0e6451a2f49c Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Wed, 12 Oct 2016 14:17:03 +0800 Subject: Cleanup webpack production config --- webpack.production.js | 3 --- 1 file changed, 3 deletions(-) (limited to 'webpack.production.js') diff --git a/webpack.production.js b/webpack.production.js index c954bd43..ce8dd27e 100644 --- a/webpack.production.js +++ b/webpack.production.js @@ -12,9 +12,6 @@ module.exports = Object.assign({}, baseConfig, { io: "socket.io-client", key: "keymaster" }), - new webpack.DefinePlugin({ - "require.specified": "require.resolve" - }), new ExtractTextPlugin("[name].css"), new webpack.optimize.CommonsChunkPlugin({ name: ["vendor", "public", "slide", "locale"], -- cgit v1.3.1 From 2cafe15e854b493d335652755b74674c7e2da4f6 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Wed, 12 Oct 2016 17:15:59 +0800 Subject: Enable production assets hash --- .gitignore | 1 + package.json | 3 ++ public/views/foot.ejs | 3 +- public/views/head.ejs | 2 +- public/views/includes/header.ejs | 3 ++ public/views/includes/scripts.ejs | 3 ++ public/views/index.ejs | 4 +-- public/views/pretty.ejs | 5 ++-- public/views/slide.ejs | 4 +-- webpack.production.js | 58 ++++++++++++++++++++++++++++++++++++++- 10 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 public/views/includes/header.ejs create mode 100644 public/views/includes/scripts.ejs (limited to 'webpack.production.js') diff --git a/.gitignore b/.gitignore index 29f916f0..9a95231c 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ public/js/config.js # ignore webpack build public/build +public/views/build diff --git a/package.json b/package.json index 5ba9101f..03333fb8 100644 --- a/package.json +++ b/package.json @@ -122,13 +122,16 @@ "url": "https://github.com/hackmdio/hackmd.git" }, "devDependencies": { + "babel-core": "^6.17.0", "babel-loader": "^6.2.5", "bower-webpack-plugin": "^0.1.9", "css-loader": "^0.25.0", + "ejs-loader": "^0.3.0", "exports-loader": "^0.6.3", "expose-loader": "^0.7.1", "extract-text-webpack-plugin": "^1.0.1", "file-loader": "^0.9.0", + "html-webpack-plugin": "^2.22.0", "imports-loader": "^0.6.5", "json-loader": "^0.5.4", "less": "^2.7.1", diff --git a/public/views/foot.ejs b/public/views/foot.ejs index 0ce4b85b..abf2da12 100644 --- a/public/views/foot.ejs +++ b/public/views/foot.ejs @@ -20,9 +20,8 @@ <% } %> - - +<%- include build/index-scripts %> diff --git a/public/views/head.ejs b/public/views/head.ejs index 72434892..f4ba108a 100644 --- a/public/views/head.ejs +++ b/public/views/head.ejs @@ -36,7 +36,7 @@ - +<%- include build/index-header %> diff --git a/public/views/includes/header.ejs b/public/views/includes/header.ejs new file mode 100644 index 00000000..89f3a0d1 --- /dev/null +++ b/public/views/includes/header.ejs @@ -0,0 +1,3 @@ +<% for (var css in htmlWebpackPlugin.files.css) { %> + +<% } %> diff --git a/public/views/includes/scripts.ejs b/public/views/includes/scripts.ejs new file mode 100644 index 00000000..4eec75e8 --- /dev/null +++ b/public/views/includes/scripts.ejs @@ -0,0 +1,3 @@ +<% for (var chunk in htmlWebpackPlugin.files.chunks) { %> + +<% } %> diff --git a/public/views/index.ejs b/public/views/index.ejs index f24a039e..0e41db57 100644 --- a/public/views/index.ejs +++ b/public/views/index.ejs @@ -27,6 +27,7 @@ + <%- include build/cover-header %> @@ -193,7 +194,6 @@ - <% if(useCDN) { %> @@ -205,7 +205,7 @@ <% } %> - + <%- include build/cover-scripts %> diff --git a/public/views/pretty.ejs b/public/views/pretty.ejs index 6f7c4e72..e617383c 100644 --- a/public/views/pretty.ejs +++ b/public/views/pretty.ejs @@ -35,6 +35,7 @@ + <%- include build/pretty-header %> @@ -97,13 +98,11 @@ <% } else { %> - <% } %> +<%- include build/pretty-scripts %> - - <%- include ga %> diff --git a/public/views/slide.ejs b/public/views/slide.ejs index c463f378..f959a346 100644 --- a/public/views/slide.ejs +++ b/public/views/slide.ejs @@ -39,6 +39,7 @@ + <%- include build/slide-header %> <% } else { %> - @@ -103,7 +103,7 @@ <% } %> - + <%- include build/slide-scripts %> diff --git a/webpack.production.js b/webpack.production.js index ce8dd27e..173ca0cd 100644 --- a/webpack.production.js +++ b/webpack.production.js @@ -1,6 +1,8 @@ var baseConfig = require('./webpackBaseConfig'); var webpack = require('webpack'); var ExtractTextPlugin = require("extract-text-webpack-plugin"); +var path = require('path'); +var HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = Object.assign({}, baseConfig, { plugins: [ @@ -19,6 +21,54 @@ module.exports = Object.assign({}, baseConfig, { filename: '[name].js', minChunks: Infinity }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/header.ejs', + chunks: ['vendor', 'index'], + filename: path.join(__dirname, 'public/views/build/index-header.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/scripts.ejs', + chunks: ['vendor', 'index'], + filename: path.join(__dirname, 'public/views/build/index-scripts.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/header.ejs', + chunks: ['vendor', 'locale'], + filename: path.join(__dirname, 'public/views/build/cover-header.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/scripts.ejs', + chunks: ['vendor', 'locale'], + filename: path.join(__dirname, 'public/views/build/cover-scripts.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/header.ejs', + chunks: ['vendor', 'public'], + filename: path.join(__dirname, 'public/views/build/pretty-header.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/scripts.ejs', + chunks: ['vendor', 'public'], + filename: path.join(__dirname, 'public/views/build/pretty-scripts.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/header.ejs', + chunks: ['vendor', 'slide'], + filename: path.join(__dirname, 'public/views/build/slide-header.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/scripts.ejs', + chunks: ['vendor', 'slide'], + filename: path.join(__dirname, 'public/views/build/slide-scripts.ejs'), + inject: false + }), new webpack.DefinePlugin({ 'process.env': { 'NODE_ENV': JSON.stringify('production') @@ -30,5 +80,11 @@ module.exports = Object.assign({}, baseConfig, { }, sourceMap: false }) - ] + ], + + output: { + path: path.join(__dirname, 'public/build'), + publicPath: '/build/', + filename: '[id].[name].[hash].js' + }, }); -- cgit v1.3.1 From 43c9f68b9a67fa7f5b3e5a7f0dc6d5f8c9114d20 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Thu, 13 Oct 2016 08:56:56 +0800 Subject: Refactor webpack module --- public/js/extra.js | 97 +++++++++++++++++++++++----------------------- public/js/index.js | 16 ++------ public/js/public.js | 4 -- public/js/slide.js | 8 ---- webpack.production.js | 5 ++- webpackBaseConfig.js | 104 +++++++++++++++++++++++++++++++++++++------------- 6 files changed, 134 insertions(+), 100 deletions(-) (limited to 'webpack.production.js') diff --git a/public/js/extra.js b/public/js/extra.js index 1dd86760..24d53fe7 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -2,6 +2,7 @@ var hljs = require('highlight.js'); var PDFObject = require('pdfobject'); var S = require('string'); var saveAs = require('file-saver').saveAs; +require('../vendor/md-toc'); //auto update last change var createtime = null; @@ -262,49 +263,49 @@ function finishView(view) { MathJax.Hub.Queue(viewAjaxCallback); } } catch (err) {} - //sequence diagram - var sequences = view.find(".sequence-diagram.raw").removeClass("raw"); - sequences.each(function (key, value) { - try { - var $value = $(value); - var $ele = $(value).parent().parent(); - - var sequence = $value; - sequence.sequenceDiagram({ - theme: 'simple' - }); - - $ele.addClass('sequence-diagram'); - $value.children().unwrap().unwrap(); - var svg = $ele.find('> svg'); - svg[0].setAttribute('viewBox', '0 0 ' + svg.attr('width') + ' ' + svg.attr('height')); - svg[0].setAttribute('preserveAspectRatio', 'xMidYMid meet'); - } catch (err) { - console.warn(err); - } - }); - //flowchart - var flow = view.find(".flow-chart.raw").removeClass("raw"); - flow.each(function (key, value) { - try { - var $value = $(value); - var $ele = $(value).parent().parent(); + //sequence diagram + var sequences = view.find(".sequence-diagram.raw").removeClass("raw"); + sequences.each(function (key, value) { + try { + var $value = $(value); + var $ele = $(value).parent().parent(); + + var sequence = $value; + sequence.sequenceDiagram({ + theme: 'simple' + }); - var chart = flowchart.parse($value.text()); - $value.html(''); - chart.drawSVG(value, { - 'line-width': 2, - 'fill': 'none', - 'font-size': '16px', - 'font-family': "'Andale Mono', monospace" - }); + $ele.addClass('sequence-diagram'); + $value.children().unwrap().unwrap(); + var svg = $ele.find('> svg'); + svg[0].setAttribute('viewBox', '0 0 ' + svg.attr('width') + ' ' + svg.attr('height')); + svg[0].setAttribute('preserveAspectRatio', 'xMidYMid meet'); + } catch (err) { + console.warn(err); + } + }); + //flowchart + var flow = view.find(".flow-chart.raw").removeClass("raw"); + flow.each(function (key, value) { + try { + var $value = $(value); + var $ele = $(value).parent().parent(); + + var chart = flowchart.parse($value.text()); + $value.html(''); + chart.drawSVG(value, { + 'line-width': 2, + 'fill': 'none', + 'font-size': '16px', + 'font-family': "'Andale Mono', monospace" + }); - $ele.addClass('flow-chart'); - $value.children().unwrap().unwrap(); - } catch (err) { - console.warn(err); - } - }); + $ele.addClass('flow-chart'); + $value.children().unwrap().unwrap(); + } catch (err) { + console.warn(err); + } + }); //graphviz var Viz = require("viz.js"); var graphvizs = view.find(".graphviz.raw").removeClass("raw"); @@ -434,14 +435,14 @@ function finishView(view) { }); //pdf view.find(".pdf.raw").removeClass("raw") - .each(function (key, value) { - var url = $(value).attr('data-pdfurl'); - var inner = $('
'); - $(this).append(inner); - PDFObject.embed(url, inner, { - height: '400px' + .each(function (key, value) { + var url = $(value).attr('data-pdfurl'); + var inner = $('
'); + $(this).append(inner); + PDFObject.embed(url, inner, { + height: '400px' + }); }); - }); //syntax highlighting view.find("pre.raw").removeClass("raw") .each(function (key, value) { diff --git a/public/js/index.js b/public/js/index.js index f8f997d8..626799c4 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -7,25 +7,16 @@ require('bootstrap/dist/css/bootstrap.css'); require('prismjs/themes/prism.css'); require('highlight.js/styles/github-gist.css'); -/* other vendors plugin */ -require('gist-embed'); -require('string'); require('prismjs'); require('prismjs/components/prism-wiki'); -require('to-markdown'); +var toMarkdown = require('to-markdown'); -require('raphael'); -require('js-sequence-diagrams'); - -require('flowchart.js'); var saveAs = require('file-saver').saveAs; -require('store'); require('js-url'); -require('visibilityjs'); -var List = require('list.js'); -require('../vendor/md-toc'); require('randomcolor'); +var List = require('list.js'); + var common = require('./common.js'); var urlpath = common.urlpath; var noteid = common.noteid; @@ -2268,6 +2259,7 @@ function havePermission() { window.havePermission = havePermission; //socket.io actions +var io = require("socket.io-client"); var socket = io.connect({ path: urlpath ? '/' + urlpath + '/socket.io/' : '', timeout: 5000 //5 secs to timeout diff --git a/public/js/public.js b/public/js/public.js index 83d94144..5fd3fd79 100644 --- a/public/js/public.js +++ b/public/js/public.js @@ -15,10 +15,6 @@ require('prismjs'); require('prismjs/components/prism-wiki'); require('to-markdown'); -require('raphael'); -require('js-sequence-diagrams'); - -require('flowchart.js'); require('file-saver'); require('store'); require('js-url'); diff --git a/public/js/slide.js b/public/js/slide.js index 6230d159..1f4892f9 100644 --- a/public/js/slide.js +++ b/public/js/slide.js @@ -4,19 +4,11 @@ require('bootstrap/dist/css/bootstrap.css'); require('prismjs/themes/prism.css'); /* other vendors plugin */ -require('gist-embed'); var S = require('string'); require('prismjs'); require('prismjs/components/prism-wiki'); require('to-markdown'); -require('raphael'); -require('js-sequence-diagrams'); - -require('flowchart.js'); -require('file-saver'); -require('store'); -require('visibilityjs'); require('../vendor/md-toc'); require('randomcolor'); diff --git a/webpack.production.js b/webpack.production.js index 173ca0cd..1c2190ab 100644 --- a/webpack.production.js +++ b/webpack.production.js @@ -11,12 +11,12 @@ module.exports = Object.assign({}, baseConfig, { Visibility: "visibilityjs", Cookies: "js-cookie", emojify: "emojify.js", - io: "socket.io-client", key: "keymaster" }), new ExtractTextPlugin("[name].css"), new webpack.optimize.CommonsChunkPlugin({ - name: ["vendor", "public", "slide", "locale"], + names: ["vendor", "public", "slide", "locale"], + children: true, async: true, filename: '[name].js', minChunks: Infinity @@ -78,6 +78,7 @@ module.exports = Object.assign({}, baseConfig, { compress: { warnings: false }, + mangle: false, sourceMap: false }) ], diff --git a/webpackBaseConfig.js b/webpackBaseConfig.js index 33753ef5..8f377d3c 100644 --- a/webpackBaseConfig.js +++ b/webpackBaseConfig.js @@ -1,6 +1,7 @@ var webpack = require('webpack'); var path = require('path'); var ExtractTextPlugin = require("extract-text-webpack-plugin"); +var HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { plugins: [ @@ -9,15 +10,63 @@ module.exports = { Visibility: "visibilityjs", Cookies: "js-cookie", emojify: "emojify.js", - io: "socket.io-client", key: "keymaster" }), new ExtractTextPlugin("[name].css"), new webpack.optimize.CommonsChunkPlugin({ - name: ["vendor", "public", "slide", "locale"], + names: ["vendor", "public", "slide", "locale"], + children: true, async: true, filename: '[name].js', minChunks: Infinity + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/header.ejs', + chunks: ['vendor', 'index'], + filename: path.join(__dirname, 'public/views/build/index-header.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/scripts.ejs', + chunks: ['vendor', 'index'], + filename: path.join(__dirname, 'public/views/build/index-scripts.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/header.ejs', + chunks: ['vendor', 'locale'], + filename: path.join(__dirname, 'public/views/build/cover-header.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/scripts.ejs', + chunks: ['vendor', 'locale'], + filename: path.join(__dirname, 'public/views/build/cover-scripts.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/header.ejs', + chunks: ['vendor', 'public'], + filename: path.join(__dirname, 'public/views/build/pretty-header.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/scripts.ejs', + chunks: ['vendor', 'public'], + filename: path.join(__dirname, 'public/views/build/pretty-scripts.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/header.ejs', + chunks: ['vendor', 'slide'], + filename: path.join(__dirname, 'public/views/build/slide-header.ejs'), + inject: false + }), + new HtmlWebpackPlugin({ + template: 'public/views/includes/scripts.ejs', + chunks: ['vendor', 'slide'], + filename: path.join(__dirname, 'public/views/build/slide-scripts.ejs'), + inject: false }) ], @@ -34,21 +83,23 @@ module.exports = { "jquery-ui/ui/widgets/tooltip", "jquery-ui/ui/widgets/controlgroup", "jquery-ui/ui/widgets/autocomplete", - "expose?LZString!lz-string", + "script!gist-embed", "expose?filterXSS!xss", "js-url", "bootstrap", "expose?Spinner!spin.js", "script!Idle.Js", - "expose?Viz!viz.js", + "expose?LZString!lz-string", "expose?ListPagination!list.pagination.js/dist/list.pagination.js", - path.join(__dirname, 'public/vendor/codemirror/codemirror.min.js'), - path.join(__dirname, 'public/vendor/select2/select2.min.js'), - path.join(__dirname, 'public/vendor/inlineAttachment/inline-attachment.js'), - path.join(__dirname, 'public/vendor/jquery-textcomplete/jquery.textcomplete.js'), - path.join(__dirname, 'public/vendor/codemirror-spell-checker/spell-checker.min.js'), - path.join(__dirname, 'public/vendor/inlineAttachment/codemirror.inline-attachment.js'), - path.join(__dirname, 'public/vendor/ot/ot.min.js') + "script!codemirror", + "script!select2", + "script!inlineAttachment", + "script!jqueryTextcomplete", + "script!codemirrorSpellChecker", + "script!codemirrorInlineAttachment", + "script!ot", + "flowchart.js", + "js-sequence-diagrams" ] }, @@ -59,11 +110,20 @@ module.exports = { }, resolve: { - root: [ + modulesDirectories: [ path.resolve(__dirname, 'src'), path.resolve(__dirname, 'node_modules') ], - extensions: ["", ".js"] + extensions: ["", ".js"], + alias: { + codemirror: path.join(__dirname, 'public/vendor/codemirror/codemirror.min.js'), + select2: path.join(__dirname, 'public/vendor/select2/select2.min.js'), + inlineAttachment: path.join(__dirname, 'public/vendor/inlineAttachment/inline-attachment.js'), + jqueryTextcomplete: path.join(__dirname, 'public/vendor/jquery-textcomplete/jquery.textcomplete.js'), + codemirrorSpellChecker: path.join(__dirname, 'public/vendor/codemirror-spell-checker/spell-checker.min.js'), + codemirrorInlineAttachment: path.join(__dirname, 'public/vendor/inlineAttachment/codemirror.inline-attachment.js'), + ot: path.join(__dirname, 'public/vendor/ot/ot.min.js') + } }, externals: { @@ -98,19 +158,11 @@ module.exports = { }, { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml" - }, { - test: /\.js/, - loader: "script-loader", - include: [ - path.join(__dirname, 'public/vendor/codemirror/codemirror.min.js'), - path.join(__dirname, 'public/vendor/inlineAttachment/inline-attachment.js'), - path.join(__dirname, 'public/vendor/jquery-textcomplete/jquery.textcomplete.js'), - path.join(__dirname, 'public/vendor/select2/select2.min.js'), - path.join(__dirname, 'public/vendor/inlineAttachment/codemirror.inline-attachment.js'), - path.join(__dirname, 'public/vendor/codemirror-spell-checker/spell-checker.min.js'), - path.join(__dirname, 'public/vendor/ot/ot.min.js') - ] - }] + }], + + noParse: [ + "gist-embed" + ] }, node: { -- cgit v1.3.1