1 | import * as webpack from 'webpack';
|
2 | import * as path from 'path';
|
3 | import * as fs from 'fs';
|
4 | import * as angularExternals from 'webpack-angular-externals';
|
5 | import * as rxjsExternals from 'webpack-rxjs-externals';
|
6 |
|
7 | const pkg = JSON.parse(fs.readFileSync('./package.json').toString());
|
8 |
|
9 | export default {
|
10 | entry: {
|
11 | 'index.umd': './src/index.ts',
|
12 | 'index.umd.min': './src/index.ts',
|
13 | },
|
14 | output: {
|
15 | path: path.join(__dirname, 'dist'),
|
16 | filename: '[name].js',
|
17 | libraryTarget: 'umd',
|
18 | library: 'ticktock'
|
19 | },
|
20 | resolve: {
|
21 | extensions: [ '.ts', '.js', '.json' ]
|
22 | },
|
23 | externals: [
|
24 | angularExternals(),
|
25 | rxjsExternals()
|
26 | ],
|
27 | devtool: 'source-map',
|
28 | module: {
|
29 | rules: [
|
30 | {
|
31 | test: /\.ts$/,
|
32 | use: [
|
33 | {
|
34 | loader: 'awesome-typescript-loader',
|
35 | options: {
|
36 | configFileName: 'tsconfig.json'
|
37 | }
|
38 | },
|
39 | {
|
40 | loader: 'angular2-template-loader'
|
41 | }
|
42 | ],
|
43 | exclude: [
|
44 | /node_modules/,
|
45 | /\.(spec|e2e)\.ts$/
|
46 | ]
|
47 | },
|
48 |
|
49 | {
|
50 | test: /\.json$/,
|
51 | use: 'json-loader'
|
52 | },
|
53 |
|
54 | {
|
55 | test: /\.css$/,
|
56 | use: ['to-string-loader', 'css-loader']
|
57 | },
|
58 |
|
59 | {
|
60 | test: /\.scss$/,
|
61 | use: ['to-string-loader', 'css-loader', 'sass-loader']
|
62 | },
|
63 |
|
64 | {
|
65 | test: /\.html$/,
|
66 | use: 'raw-loader'
|
67 | }
|
68 | ]
|
69 | },
|
70 | plugins: [
|
71 | new webpack.ContextReplacementPlugin(
|
72 | /angular(\\|\/)core(\\|\/)@angular/,
|
73 | path.join(__dirname, 'src')
|
74 | ),
|
75 |
|
76 | new webpack.optimize.UglifyJsPlugin({
|
77 | include: /\.min\.js$/,
|
78 | sourceMap: true
|
79 | }),
|
80 |
|
81 | new webpack.BannerPlugin({
|
82 | banner: `
|
83 | /**
|
84 | * ${pkg.name} - ${pkg.description}
|
85 | * @version v${pkg.version}
|
86 | * @author ${pkg.author.name}
|
87 | * @link ${pkg.homepage}
|
88 | * @license ${pkg.license}
|
89 | */
|
90 | `.trim(),
|
91 | raw: true,
|
92 | entryOnly: true
|
93 | })
|
94 |
|
95 | ]
|
96 | } as webpack.Configuration;
|