UNPKG

2.62 kBJavaScriptView Raw
1/**
2 * Adapted from angular2-webpack-starter
3 */
4
5const helpers = require('./helpers'),
6 webpack = require('webpack'),
7 LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
8
9/**
10 * Webpack Plugins
11 */
12
13module.exports = {
14
15 /**
16 * Source map for Karma from the help of karma-sourcemap-loader & karma-webpack
17 *
18 * Do not change, leave as is or it wont work.
19 * See: https://github.com/webpack/karma-webpack#source-maps
20 */
21 devtool: 'inline-source-map',
22
23 resolve: {
24 extensions: ['.ts', '.js'],
25 modules: [helpers.root('src'), 'node_modules']
26 },
27
28 module: {
29 rules: [{
30 enforce: 'pre',
31 test: /\.ts$/,
32 loader: 'tslint-loader',
33 exclude: [helpers.root('node_modules')]
34 }, {
35 enforce: 'pre',
36 test: /\.js$/,
37 loader: 'source-map-loader',
38 exclude: [
39 // these packages have problems with their sourcemaps
40 helpers.root('node_modules/rxjs'),
41 helpers.root('node_modules/@angular')
42 ]
43 }, {
44 test: /\.ts$/,
45 loader: 'awesome-typescript-loader',
46 query: {
47 // use inline sourcemaps for "karma-remap-coverage" reporter
48 sourceMap: false,
49 inlineSourceMap: true,
50 module: "commonjs",
51 removeComments: true
52 },
53 exclude: [/\.e2e\.ts$/]
54 }, {
55 enforce: 'post',
56 test: /\.(js|ts)$/,
57 loader: 'istanbul-instrumenter-loader',
58 include: helpers.root('src'),
59 exclude: [/\.spec\.ts$/, /\.e2e\.ts$/, /node_modules/]
60 }],
61 },
62
63 plugins: [
64 // fix the warning in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
65 new webpack.ContextReplacementPlugin(
66 /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
67 helpers.root('./src')
68 ),
69
70 new LoaderOptionsPlugin({
71 debug: true,
72 options: {
73
74 /**
75 * Static analysis linter for TypeScript advanced options configuration
76 * Description: An extensible linter for the TypeScript language.
77 *
78 * See: https://github.com/wbuchwalter/tslint-loader
79 */
80 'tslint-loader': {
81 emitErrors: false,
82 failOnHint: false,
83 resourcePath: 'src'
84 },
85
86 }
87 })
88 ]
89};