forked from simonbengtsson/jsPDF-AutoTable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
63 lines (60 loc) · 1.67 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
const webpack = require('webpack')
const path = require('path')
const TerserPlugin = require('terser-webpack-plugin')
const packageJson = require('./package.json')
module.exports = (env) => {
const minified = !!env.minified
const newVersion = packageJson.version
const currentYear = new Date().getFullYear()
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 this !== 'undefined' ? this : window",
},
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,
},
}
}