-
-
Notifications
You must be signed in to change notification settings - Fork 624
/
webpack.config.mjs
68 lines (65 loc) · 1.95 KB
/
webpack.config.mjs
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
import webpack from 'webpack'
import path from 'path'
import fs from 'fs'
import TerserPlugin from 'terser-webpack-plugin'
import * as url from 'url'
export default (env) => {
const minified = !!env.minified
const packageJsonStr = fs.readFileSync('package.json')
const packageJson = JSON.parse(packageJsonStr)
const newVersion = packageJson.version
const currentYear = new Date().getFullYear()
const __dirname = url.fileURLToPath(new url.URL('.', import.meta.url))
const outputPath = path.join(__dirname, './')
return {
entry: {
[`dist/jspdf.plugin.autotable${minified ? '.min' : ''}`]: './src/main.ts',
},
resolve: {
extensions: ['.ts', '.js'],
},
output: {
path: outputPath,
filename: '[name].js',
libraryTarget: 'umd',
globalObject:
"typeof globalThis !== 'undefined' ? globalThis : typeof this !== 'undefined' ? this : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : global ",
},
module: {
rules: [{ test: /\.ts$/, use: [{ loader: 'ts-loader' }] }],
},
externals: {
jspdf: {
commonjs: 'jspdf',
commonjs2: 'jspdf',
amd: 'jspdf',
root: 'jspdf',
},
},
performance: { hints: false },
devServer: {
static: {
directory: '.',
},
port: 9000,
proxy: {
'/libs/jspdf.plugin.autotable.js': {
target: 'http://localhost:9000/dist/',
pathRewrite: { '^/libs': '' },
},
},
},
plugins: [
new webpack.BannerPlugin(`
jsPDF AutoTable plugin v${newVersion}
Copyright (c) ${currentYear} Simon Bengtsson, https://github.com/simonbengtsson/jsPDF-AutoTable
Licensed under the MIT License.
http://opensource.org/licenses/mit-license
`),
],
optimization: {
minimizer: [new TerserPlugin({ extractComments: false })],
minimize: !!minified,
},
}
}