summaryrefslogtreecommitdiff
path: root/webpackBaseConfig.js
blob: 496afce4f1cd52c754a432ab61d3207f65c0ba45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
    plugins: [
        new webpack.ProvidePlugin({
            Visibility: "visibilityjs",
            Cookies: "js-cookie",
            key: "keymaster",
            $: "jquery",
            jQuery: "jquery",
            "window.jQuery": "jquery",
            "moment": "moment",
            "Handlebars": "handlebars"
        }),
        new webpack.optimize.OccurrenceOrderPlugin(true),
        new webpack.optimize.CommonsChunkPlugin({
            names: ["cover", "index", "pretty", "slide", "vendor"],
            children: true,
            async: true,
            filename: '[name].js',
            minChunks: Infinity
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/header.ejs',
            chunks: ['font', 'index-styles', 'index'],
            filename: path.join(__dirname, 'public/views/build/index-header.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/header.ejs',
            chunks: ['font-pack', 'index-styles-pack', 'index-styles', 'index'],
            filename: path.join(__dirname, 'public/views/build/index-pack-header.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/scripts.ejs',
            chunks: ['index'],
            filename: path.join(__dirname, 'public/views/build/index-scripts.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/scripts.ejs',
            chunks: ['common', 'index-pack'],
            filename: path.join(__dirname, 'public/views/build/index-pack-scripts.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/header.ejs',
            chunks: ['font', 'cover'],
            filename: path.join(__dirname, 'public/views/build/cover-header.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/header.ejs',
            chunks: ['font-pack', 'cover-styles-pack', 'cover'],
            filename: path.join(__dirname, 'public/views/build/cover-pack-header.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/scripts.ejs',
            chunks: ['cover'],
            filename: path.join(__dirname, 'public/views/build/cover-scripts.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/scripts.ejs',
            chunks: ['common', 'cover-pack'],
            filename: path.join(__dirname, 'public/views/build/cover-pack-scripts.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/header.ejs',
            chunks: ['font', 'pretty-styles', 'pretty'],
            filename: path.join(__dirname, 'public/views/build/pretty-header.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/header.ejs',
            chunks: ['font-pack', 'pretty-styles-pack', 'pretty-styles', 'pretty'],
            filename: path.join(__dirname, 'public/views/build/pretty-pack-header.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/scripts.ejs',
            chunks: ['pretty'],
            filename: path.join(__dirname, 'public/views/build/pretty-scripts.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/scripts.ejs',
            chunks: ['common', 'pretty-pack'],
            filename: path.join(__dirname, 'public/views/build/pretty-pack-scripts.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/header.ejs',
            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: ['slide'],
            filename: path.join(__dirname, 'public/views/build/slide-scripts.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/scripts.ejs',
            chunks: ['slide-pack'],
            filename: path.join(__dirname, 'public/views/build/slide-pack-scripts.ejs'),
            inject: false
        }),
        new CopyWebpackPlugin([
            {
                context: path.join(__dirname, 'node_modules/mathjax'),
                from: {
                    glob: '**/*',
                    dot: false
                },
                to: 'MathJax/'
            },
            {
                context: path.join(__dirname, 'node_modules/emojify.js'),
                from: {
                    glob: '**/*',
                    dot: false
                },
                to: 'emojify.js/'
            },
            {
                context: path.join(__dirname, 'node_modules/reveal.js'),
                from: {
                    glob: '**/*',
                    dot: false
                },
                to: 'reveal.js/'
            }
        ])
    ],

    entry: {
        font: path.join(__dirname, 'public/css/google-font.css'),
        "font-pack": path.join(__dirname, 'public/css/font.css'),
        common: [
            "expose?jQuery!expose?$!jquery",
            "velocity-animate",
            "imports?$=jquery!jquery-mousewheel",
            "bootstrap"
        ],
        cover: [
            path.join(__dirname, 'public/js/cover.js')
        ],
        "cover-styles-pack": [
            path.join(__dirname, 'node_modules/bootstrap/dist/css/bootstrap.min.css'),
            path.join(__dirname, 'node_modules/font-awesome/css/font-awesome.min.css'),
            path.join(__dirname, 'public/css/bootstrap-social.css'),
            path.join(__dirname, 'node_modules/select2/select2.css'),
            path.join(__dirname, 'node_modules/select2/select2-bootstrap.css'),
        ],
        "cover-pack": [
            "bootstrap-validator",
            "script!listPagnation",
            "expose?select2!select2",
            "expose?moment!moment",
            "script!js-url",
            path.join(__dirname, 'public/js/cover.js')
        ],
        index: [
            "script!jquery-ui-resizable",
            "script!js-url",
            "expose?filterXSS!xss",
            "script!Idle.Js",
            "expose?LZString!lz-string",
            "script!codemirror",
            "script!inlineAttachment",
            "script!jqueryTextcomplete",
            "script!codemirrorSpellChecker",
            "script!codemirrorInlineAttachment",
            "script!ot",
            "flowchart.js",
            "js-sequence-diagrams",
            "expose?RevealMarkdown!reveal-markdown",
            path.join(__dirname, 'public/js/google-drive-upload.js'),
            path.join(__dirname, 'public/js/google-drive-picker.js'),
            path.join(__dirname, 'public/js/index.js')
        ],
        "index-styles": [
            path.join(__dirname, 'public/vendor/jquery-ui/jquery-ui.min.css'),
            path.join(__dirname, 'public/vendor/codemirror-spell-checker/spell-checker.min.css'),
            path.join(__dirname, 'node_modules/codemirror/lib/codemirror.css'),
            path.join(__dirname, 'node_modules/codemirror/addon/fold/foldgutter.css'),
            path.join(__dirname, 'node_modules/codemirror/addon/display/fullscreen.css'),
            path.join(__dirname, 'node_modules/codemirror/addon/dialog/dialog.css'),
            path.join(__dirname, 'node_modules/codemirror/addon/scroll/simplescrollbars.css'),
            path.join(__dirname, 'node_modules/codemirror/addon/search/matchesonscrollbar.css'),
            path.join(__dirname, 'node_modules/codemirror/theme/monokai.css'),
            path.join(__dirname, 'node_modules/codemirror/theme/one-dark.css'),
            path.join(__dirname, 'node_modules/codemirror/mode/tiddlywiki/tiddlywiki.css'),
            path.join(__dirname, 'node_modules/codemirror/mode/mediawiki/mediawiki.css'),
            path.join(__dirname, 'public/css/github-extract.css'),
            path.join(__dirname, 'public/vendor/showup/showup.css'),
            path.join(__dirname, 'public/css/mermaid.css'),
            path.join(__dirname, 'public/css/markdown.css'),
            path.join(__dirname, 'public/css/slide-preview.css')
        ],
        "index-styles-pack": [
            path.join(__dirname, 'node_modules/bootstrap/dist/css/bootstrap.min.css'),
            path.join(__dirname, 'node_modules/font-awesome/css/font-awesome.min.css'),
            path.join(__dirname, 'public/css/bootstrap-social.css'),
            path.join(__dirname, 'node_modules/ionicons/css/ionicons.min.css'),
            path.join(__dirname, 'node_modules/octicons/octicons/octicons.css')
        ],
        "index-pack": [
            "expose?Spinner!spin.js",
            "script!jquery-ui-resizable",
            "bootstrap-validator",
            "expose?jsyaml!js-yaml",
            "script!mermaid",
            "expose?moment!moment",
            "script!js-url",
            "script!handlebars",
            "expose?hljs!highlight.js",
            "expose?emojify!emojify.js",
            "expose?filterXSS!xss",
            "script!Idle.Js",
            "script!gist-embed",
            "expose?LZString!lz-string",
            "script!codemirror",
            "script!inlineAttachment",
            "script!jqueryTextcomplete",
            "script!codemirrorSpellChecker",
            "script!codemirrorInlineAttachment",
            "script!ot",
            "flowchart.js",
            "js-sequence-diagrams",
            "expose?Viz!viz.js",
            "expose?io!socket.io-client",
            "expose?RevealMarkdown!reveal-markdown",
            path.join(__dirname, 'public/js/google-drive-upload.js'),
            path.join(__dirname, 'public/js/google-drive-picker.js'),
            path.join(__dirname, 'public/js/index.js')
        ],
        pretty: [
            "expose?filterXSS!xss",
            "flowchart.js",
            "js-sequence-diagrams",
            "expose?RevealMarkdown!reveal-markdown",
            path.join(__dirname, 'public/js/pretty.js')
        ],
        "pretty-styles": [
            path.join(__dirname, 'public/css/github-extract.css'),
            path.join(__dirname, 'public/css/mermaid.css'),
            path.join(__dirname, 'public/css/markdown.css'),
            path.join(__dirname, 'public/css/slide-preview.css')
        ],
        "pretty-styles-pack": [
            path.join(__dirname, 'node_modules/bootstrap/dist/css/bootstrap.min.css'),
            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')
        ],
        "pretty-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",
            "expose?RevealMarkdown!reveal-markdown",
            path.join(__dirname, 'public/js/pretty.js')
        ],
        slide: [
            "bootstrap-tooltip",
            "expose?filterXSS!xss",
            "flowchart.js",
            "js-sequence-diagrams",
            "expose?RevealMarkdown!reveal-markdown",
            path.join(__dirname, 'public/js/slide.js')
        ],
        "slide-styles": [
            path.join(__dirname, 'public/vendor/bootstrap/tooltip.min.css'),
            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')
        ],
        "slide-pack": [
            "expose?jQuery!expose?$!jquery",
            "velocity-animate",
            "imports?$=jquery!jquery-mousewheel",
            "bootstrap-tooltip",
            "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",
            "expose?RevealMarkdown!reveal-markdown",
            path.join(__dirname, 'public/js/slide.js')
        ]
    },

    output: {
        path: path.join(__dirname, 'public/build'),
        publicPath: '/build/',
        filename: '[name].js',
        baseUrl: '<%- url %>'
    },

    resolve: {
        modulesDirectories: [
            path.resolve(__dirname, 'src'),
            path.resolve(__dirname, 'node_modules')
        ],
        extensions: ["", ".js"],
        alias: {
            codemirror: path.join(__dirname, 'node_modules/codemirror/codemirror.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'),
            listPagnation: path.join(__dirname, 'node_modules/list.pagination.js/dist/list.pagination.min.js'),
            mermaid: path.join(__dirname, 'node_modules/mermaid/dist/mermaid.min.js'),
            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'),
            "reveal-markdown": path.join(__dirname, 'public/js/reveal-markdown.js')
        }
    },

    externals: {
        "viz.js": "Viz",
        "socket.io-client": "io",
        "lodash": "_",
        "jquery": "$",
        "moment": "moment",
        "handlebars": "Handlebars",
        "highlight.js": "hljs",
        "select2": "select2"
    },

    module: {
        loaders: [{
            test: /\.json$/,
            loader: 'json-loader'
        }, {
            test: /\.css$/,
            loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
        }, {
            test: /\.scss$/,
            loader: ExtractTextPlugin.extract('style-loader', 'sass-loader')
        }, {
            test: /\.less$/,
            loader: ExtractTextPlugin.extract('style-loader', 'less-loader')
        }, {
            test: require.resolve("js-sequence-diagrams"),
            loader: "imports?Raphael=raphael"
        }, {
            test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
            loader: "file"
        }, {
            test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
            loader: "url?prefix=font/&limit=5000"
        }, {
            test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
            loader: "url?limit=10000&mimetype=application/octet-stream"
        }, {
            test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
            loader: "url?limit=10000&mimetype=image/svg+xml"
        }, {
            test: /\.png(\?v=\d+\.\d+\.\d+)?$/,
            loader: "url?limit=10000&mimetype=image/png"
        }, {
            test: /\.gif(\?v=\d+\.\d+\.\d+)?$/,
            loader: "url?limit=10000&mimetype=image/gif"
        }]
    },

    node: {
        fs: "empty"
    }
};