forked from OneNoteDev/OneNoteApi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
68 lines (62 loc) · 1.7 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
const path = require("path");
const webpack = require("webpack");
const WebpackMerge = require('webpack-merge');
const DtsBundlePlugin = require('dts-bundle-webpack');
const IS_PROD = process.env.NODE_ENV === "production";
const base = {
mode: "development",
entry: {
OneNoteApi: `./src/scripts/oneNoteApi`
},
output: {
path: path.join(__dirname, 'dist'),
publicPath: "/dist/",
filename: '[name].js',
library: 'OneNoteApi',
libraryTarget: 'umd',
umdNamedDefine: true
},
target: 'web',
devtool: 'cheap-module-eval-source-map',
resolve: {
extensions: ['.js', '.ts', '.tsx'],
},
plugins: [
new webpack.ProvidePlugin({
Promise: 'es6-promise'
})
],
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader'
},
]
}
};
const prod = {
devtool: 'source-map',
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new DtsBundlePlugin({
name: 'OneNoteApi',
main: path.resolve(__dirname, 'dist', 'types', 'scripts', 'oneNoteApi.d.ts'),
out: path.resolve(__dirname, 'dist', 'OneNoteApi.d.ts'),
verbose: true,
removeSource: false,
outputAsModuleFolder: true,
emitOnIncludedFileNotFound: true,
headerText: `TypeScript Definition for OneNoteApi`
})
]
};
let webpackConfiguration = base;
if (IS_PROD) {
webpackConfiguration = WebpackMerge(webpackConfiguration, prod);
}
module.exports = webpackConfiguration;