-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
72 lines (71 loc) · 1.72 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
/* eslint-disable */
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
mode: 'development',
entry: {
main: './src/main.tsx',
ocr: './src/ocr-tool.ts',
},
devtool: 'source-map',
output: {
clean: true,
path: __dirname + '/dist',
filename: 'bundle/[name].[contenthash].js',
},
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: ['.ts', '.tsx', '.js'],
// Add support for TypeScripts fully qualified ESM imports.
extensionAlias: {
'.js': ['.js', '.ts'],
'.cjs': ['.cjs', '.cts'],
'.mjs': ['.mjs', '.mts'],
},
},
module: {
rules: [
// all files with a `.ts`, `.cts`, `.mts` or `.tsx` extension will be handled by `ts-loader`
{
test: /\.([cm]?ts|tsx)$/,
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
],
},
externals: {
// require("jquery") is external and available
// on the global var jQuery
jquery: 'jQuery',
},
plugins: [
new HtmlWebpackPlugin({
template: __dirname + '/src/index.template.html',
filename: __dirname + '/dist/index.html',
inject: 'body',
scriptLoading: 'blocking',
chunks: ['main'],
minify: false,
}),
new HtmlWebpackPlugin({
template: __dirname + '/src/ocr.template.html',
filename: __dirname + '/dist/ocr.html',
inject: 'body',
scriptLoading: 'blocking',
chunks: ['ocr'],
minify: false,
}),
],
devServer: {
static: [
'static',
'images',
'id4-to-location',
'by-location',
'rotated-assets',
'styles',
].map((dir) => ({ directory: dir, publicPath: `/${dir}` })),
port: 8080,
},
};