aboutsummaryrefslogtreecommitdiffstats
path: root/webpack/webpack.test.js
blob: 9057d4e69f12c3d9fb1ac68eb4af8fb3595a6863 (plain)
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
/****************************************************************************************
 * Webpack test configuration file
 * Using the current configuration we are able to bundle all the files we need for our
 * unit testings.
 ***************************************************************************************/


'use strict';

/**
 * Dependencies:
 * path: node library for resolving full path names
 * webpack: for use in our testings
 */
const path = require('path');
const webpack = require('webpack');
const helpers = require('./helpers');
module.exports = {
    /**
     * Choose a developer tool to enhance debugging. inline-source-map - A SourceMap is added as DataUrl to the JavaScript file.
     */
    devtool: 'inline-source-map',

    /**
     * Set webpack loaders and preloaders for typescript, angular2, SASS and HTML,
     * so that webpack will be able to process and bundle them.
     */
    module: {

        rules: [
            {
                test: /.ts$/,
                exclude: /node_modules/,
                use: [
                    'awesome-typescript-loader',
                    'angular2-template-loader',
                    'angular2-router-loader'
                ]
            },
            { test: /\.html$/, loader: "html-loader" },
            {
                test: /.scss$/,
                use: ['style-loader', 'css-loader', 'sass-loader'],
                include: path.resolve(__dirname, '../')
            },

        ]
    },

    plugins: [
        // Workaround for angular/angular#11580
        new webpack.ContextReplacementPlugin(
            // The (\\|\/) piece accounts for path separators in *nix and Windows
            ///angular(\\|\/)core(\\|\/)@angular/,
            /@angular(\\|\/)core(\\|\/)/,
            helpers.root('./src'), // location of your src
            {} // a map of your routes
        ),
    ],

    /**
     * This section lets Webpack know which types of file extensions it should be loading.
     */
    resolve: {
        extensions: ['.js', '.ts'],
        modules: [
            path.resolve('.', 'src'),
            'node_modules'
        ]
    },
};