-
Notifications
You must be signed in to change notification settings - Fork 418
/
webpack.config.js
92 lines (78 loc) · 3.05 KB
/
webpack.config.js
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
// @ts-check
const path = require('path');
const webpack = require('webpack');
/** @type {webpack.Configuration} */
const shared = {
mode: 'production',
watchOptions: {
ignored: ['BookReader/**', 'node_modules/**', 'tests/**'],
},
target: ['web', 'es5'],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules[/\\](?!(lit-element|lit-html|lit|@lit)[/\\]).*/,
loader: "babel-loader",
},
],
},
output: {
filename: '[name]',
path: path.resolve(__dirname, 'BookReader'),
},
};
/** @type {webpack.Configuration[]} */
module.exports = [
{
...shared,
// Output file -> srcfile
entry: {
// Polyfill bundles
'webcomponents-bundle.js': { import: '@webcomponents/webcomponentsjs/webcomponents-bundle.js' },
// BookReader
'BookReader.js': './src/BookReader.js',
// Plugins (sorted!)
'plugins/plugin.archive_analytics.js': { import: './src/plugins/plugin.archive_analytics.js', dependOn: 'BookReader.js' },
'plugins/plugin.autoplay.js': { import: './src/plugins/plugin.autoplay.js', dependOn: 'BookReader.js' },
'plugins/plugin.chapters.js': { import: './src/plugins/plugin.chapters.js', dependOn: 'BookReader.js' },
'plugins/plugin.iframe.js': { import: './src/plugins/plugin.iframe.js', dependOn: 'BookReader.js' },
'plugins/plugin.iiif.js': { import: './src/plugins/plugin.iiif.js', dependOn: 'BookReader.js' },
'plugins/plugin.resume.js': { import: './src/plugins/plugin.resume.js', dependOn: 'BookReader.js' },
'plugins/plugin.search.js': { import: './src/plugins/search/plugin.search.js', dependOn: 'BookReader.js' },
'plugins/plugin.text_selection.js': { import: './src/plugins/plugin.text_selection.js', dependOn: 'BookReader.js' },
'plugins/plugin.tts.js': { import: './src/plugins/tts/plugin.tts.js', dependOn: 'BookReader.js' },
'plugins/plugin.url.js': { import: './src/plugins/url/plugin.url.js', dependOn: 'BookReader.js' },
'plugins/plugin.vendor-fullscreen.js': { import: './src/plugins/plugin.vendor-fullscreen.js', dependOn: 'BookReader.js' },
'ia-bookreader-bundle.js': { import: './src/ia-bookreader/ia-bookreader.js', dependOn: 'BookReader.js' },
},
externals: {
// Anytime 'jquery' is imported, use the at runtime globally defined jQuery
// instead of bundling a copy of jquery at compile-time.
jquery: 'jQuery',
},
plugins: [
new webpack.ProvidePlugin({
// Make $ and jQuery available without importing
$: 'jquery',
jQuery: 'jquery',
}),
],
output: {
filename: '[name]',
path: path.resolve(__dirname, 'BookReader'),
},
// Accurate source maps at the expense of build time.
// The source map is intentionally exposed
// to users via sourceMapFilename for prod debugging.
devtool: 'source-map',
},
// jQuery gets its own build, so that it can be used as an "external" in
// everything else.
{
...shared,
entry: {
'jquery-3.js': { import: './src/jquery-wrapper.js' },
},
},
];