-
Notifications
You must be signed in to change notification settings - Fork 22
/
webpack-umd.config.ts
98 lines (89 loc) · 2.16 KB
/
webpack-umd.config.ts
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import * as webpack from 'webpack';
import * as path from 'path';
import * as fs from 'fs';
import * as angularExternals from 'webpack-angular-externals';
import * as rxjsExternals from 'webpack-rxjs-externals';
const pkg = JSON.parse(fs.readFileSync('./package.json').toString());
export default {
entry: {
'index.umd': './src/app/cuppa-ng2-slidemenu/index.ts',
'index.umd.min': './src/app/cuppa-ng2-slidemenu/index.ts',
'angular2-multiselect-dropdown.umd': './src/app/cuppa-ng2-slidemenu/cuppa-ng2-slidemenu.ts',
'angular2-multiselect-dropdown.umd.min': './src/app/cuppa-ng2-slidemenu/cuppa-ng2-slidemenu.ts'
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
libraryTarget: 'umd',
library: 'ticktock'
},
resolve: {
extensions: [ '.ts', '.js', '.json' ]
},
externals: [
angularExternals(),
rxjsExternals()
],
devtool: 'source-map',
module: {
rules: [
{
test: /\.ts$/,
use: [
{
loader: 'awesome-typescript-loader',
options: {
configFileName: 'tsconfig.json'
}
},
{
loader: 'angular2-template-loader'
}
],
exclude: [
/node_modules/,
/\.(spec|e2e)\.ts$/
]
},
{
test: /\.json$/,
use: 'json-loader'
},
{
test: /\.css$/,
use: ['to-string-loader', 'css-loader']
},
{
test: /\.scss$/,
use: ['to-string-loader', 'css-loader', 'sass-loader']
},
{
test: /\.html$/,
use: 'raw-loader'
}
]
},
plugins: [
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)@angular/,
path.join(__dirname, 'src')
),
new webpack.optimize.UglifyJsPlugin({
include: /\.min\.js$/,
sourceMap: true
}),
new webpack.BannerPlugin({
banner: `
/**
* ${pkg.name} - ${pkg.description}
* @version v${pkg.version}
* @author ${pkg.author.name}
* @link ${pkg.homepage}
* @license ${pkg.license}
*/
`.trim(),
raw: true,
entryOnly: true
})
]
} as webpack.Configuration;