-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
159 lines (156 loc) · 5.13 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
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
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const WebpackAutoInject = require('webpack-auto-inject-version-next');
const PATHS = {
vendor: path.join(__dirname, 'src/js/vendors/'),
modules: path.join(__dirname, 'node_modules/')
}
module.exports = {
entry: {
text: ['./src/text-index.js'],
text_lite: ['./src/author-index.js'],
image_m2: ['./src/image-index-m2.js'],
video_vjs: ['./src/video-index-vjs.js']
},
plugins: [
new webpack.ProvidePlugin({
"jquery": require.resolve('jquery'),
"$": require.resolve('jquery'),
'jQuery': require.resolve('jquery'),
_: require.resolve('lodash'),
'toastr': require.resolve('toastr'),
"videojs": require.resolve('video.js')
}),
new MiniCssExtractPlugin({
filename: 'dist/hxighlighter_[name].css',
chunkFilename: "[id].css"
}),
new webpack.DefinePlugin({
'require.specified': 'require.resolve'
}),
new webpack.IgnorePlugin({
resourceRegExp: /^codemirror$/
}),
new WebpackAutoInject({
components: {
InjectAsComment: true,
InjectByTag: false
},
componentsOptions: {
InjectAsComment: {
tag: 'Version: {version} - {date}',
dateFormat: 'dddd, mmmm dS, yyyy, h:MM:ss TT',
multiLineCommentType: false,
}
}
}),
],
output: {
path: __dirname,
filename: 'dist/hxighlighter_[name].js',
assetModuleFilename: '[hash][ext][query]'
},
resolve: {
extensions: ['.js'],
// Note: mainFields prioritizes the "main" entrypoint to deal with a video.js conflict
// between video.es.js and video.cjs.js
mainFields: ['main', 'module'],
alias: {
'annotator': PATHS.vendor + 'Annotator/annotator.ui.js',
'jQuery': 'jquery',
'CodeMirror': 'codemirror',
'jquery-tokeninput': PATHS.modules + 'jquery.tokeninput/',
'handlebars': PATHS.modules + 'handlebars/dist/handlebars.min.js',
'videojs': PATHS.modules + 'video.js',
'videojs-transcript': PATHS.modules + 'videojs-transcript-ac/dist/videojs-transcript.js',
'videojs-youtube': PATHS.modules + 'videojs-youtube/dist/Youtube.js'
}
},
optimization: {
minimize: false,
minimizer: [
// For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
`...`,
new CssMinimizerPlugin(),
],
},
externals: {
'Mirador': 'Mirador'
},
module: {
rules: [
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: '../',
}
},
"css-loader"
]
},
{
test: /\.(eot|ttf|woff(2)?)(\?v=\d+\.\d+\.\d+)?/,
type: 'asset/resource',
generator: {
publicPath: 'hxighlighter/fonts/',
outputPath: 'dist/hxighlighter/fonts/'
}
},
{
test: /\.(gif|svg|png|jpg)(\?v=\d+\.\d+\.\d+)?/,
type: 'asset/inline'
},
{
test: /annotator\.ui\.js/,
use: [{
loader: "imports-loader",
options: {
imports: [
"defaults jquery $",
"defaults jquery window.jQuery",
"defaults jquery jQuery"
]
}
}]
},
// {
// test: /mirador\.js/,
// use: 'script-loader'
// },
{
test: /videojs-transcript.js/,
use: [{
loader: "imports-loader",
options: {
imports: [
"defaults videojs videojs"
]
}
}]
},
{
test: /(floating|sidebar)\.html$/,
use: ['underscore-template-loader']
},
{ test: /\.handlebars$/, loader: "handlebars-loader" },
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
},
performance: {
'hints': false
}
}