This repository has been archived by the owner on Dec 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.umd.js
88 lines (88 loc) · 2.45 KB
/
webpack.config.umd.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const path = require('path');
const webpack = require('webpack');
const IS_PROD = process.argv.indexOf('-p') > -1;
const StringReplacePlugin = require('string-replace-webpack-plugin');
const LoaderOptionsPlugin = require("webpack/lib/LoaderOptionsPlugin");
const TOKENS = {
VERSION: JSON.stringify(require('./package.json').version).replace(/['"]+/g, '')
};
module.exports = {
entry: './src/index.ts',
output: {
path: path.join(__dirname, 'dist', 'umd'),
filename: './stormpath-sdk-angular.js',
libraryTarget: 'umd',
library: 'Stormpath'
},
externals: {
'@angular/core': {
root: ['ng', 'core'],
commonjs: '@angular/core',
commonjs2: '@angular/core',
amd: '@angular/core'
},
'@angular/common': {
root: ['ng', 'common'],
commonjs: '@angular/common',
commonjs2: '@angular/common',
amd: '@angular/common'
}
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.ts$/, enforce: 'pre', loader: 'tslint-loader', exclude: /node_modules/
},
{
test: /\.ts$/,
loaders: ['awesome-typescript-loader', 'angular2-template-loader?keepUrl=true'],
exclude: [/\.(spec|e2e)\.ts$/, /node_modules/]
},
/* Replace version from package.json */
{
test: /\.config.ts$/,
loader: StringReplacePlugin.replace({
replacements: [{
pattern: /\${(.*)}/g,
replacement: function (match, p1, offset, string) {
return TOKENS[p1];
}
}]
})
},
/* Embed files. */
{
test: /\.(html|css)$/,
loader: 'raw-loader',
exclude: /\.async\.(html|css)$/
},
/* Async loading. */
{
test: /\.async\.(html|css)$/,
loaders: ['file?name=[name].[hash].[ext]', 'extract']
}
]
},
resolve: {
extensions: ['.ts', '.js']
},
plugins: [
new webpack.DefinePlugin({
ENV: JSON.stringify(IS_PROD ? 'production' : 'development'),
VERSION: JSON.stringify(require('./package.json').version)
}),
new webpack.HotModuleReplacementPlugin(),
// the LoaderOptionsPlugin is necessary to configure tslint, but causes issues with StringReplacePlugin
// https://github.com/wbuchwalter/tslint-loader/issues/38
/*new LoaderOptionsPlugin({
options: {
tslint: {
emitErrors: false,
failOnHint: false
}
}
}),*/
new StringReplacePlugin()
]
};