forked from simonbengtsson/jsPDF-AutoTable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
68 lines (64 loc) · 2.01 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
var webpack = require("webpack");
var fs = require("fs");
var path = require('path');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
var newVersion = require('./package.json').version;
var readme = "" + fs.readFileSync('./README.md');
var newVersionStr = "cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/" + newVersion + "/jspdf.plugin.autotable.js";
readme = readme.replace(/cdnjs\.cloudflare\.com\/ajax\/libs\/jspdf-autotable\/.*\/jspdf\.plugin\.autotable\.js/, newVersionStr);
fs.writeFileSync('./README.md', readme);
module.exports = {
entry: {
"dist/jspdf.plugin.autotable": "./src/main.ts",
"dist/jspdf.plugin.autotable.min": "./src/main.ts",
},
resolve: {
extensions: [".ts", ".js"]
},
output: {
path: path.join(__dirname, './'),
filename: "[name].js",
libraryTarget: "umd",
},
module: {
rules: [
{ test: /\.ts$/, use: [{loader: 'ts-loader'}] }
]
},
externals: {
"jspdf": {
commonjs: "jspdf",
commonjs2: "jspdf",
amd: "jspdf",
root: "jsPDF"
}
},
performance: { hints: false },
devServer: {
contentBase: ".",
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) 2014 Simon Bengtsson, https://github.com/simonbengtsson/jsPDF-AutoTable
Licensed under the MIT License.
http://opensource.org/licenses/mit-license
*/if (typeof window === 'object') window.jspdfAutoTableVersion = '" + newVersion + "';/*"
`)
],
optimization: {
minimize: true,
minimizer: [
new UglifyJSPlugin({
include: /\.min\.js$/,
})
]
}
};