This repository was archived by the owner on Sep 11, 2024. It is now read-only.
forked from as-ideas/oil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.test.js
executable file
·112 lines (102 loc) · 2.84 KB
/
webpack.test.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
const helpers = require('./helpers');
const util = require('util');
const debugLog = util.debuglog('oil-debug');
const webpackMerge = require('webpack-merge'); // used to merge webpack configs
const commonConfig = require('./webpack.common.js'); // the settings that are common
const appConfig = helpers.getAppConfig();
/**
* Webpack Plugins
*/
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
const SourceMapDevToolPlugin = require('webpack/lib/SourceMapDevToolPlugin');
const DefinePlugin = require('webpack/lib/DefinePlugin');
/**
* Webpack Constants
*/
const ENV = process.env.ENV || process.env.NODE_ENV || 'test';
/**
* Webpack configuration
*
* See: http://webpack.github.io/docs/configuration.html#cli
*/
let config = webpackMerge(commonConfig, {
/**
* Webpack mode (see https://webpack.js.org/concepts/mode/ for details).
*/
mode: 'development',
/**
* Source map for Karma from the help of karma-sourcemap-loader & karma-webpack
*
* Do not change, leave as is or it wont work.
* See: https://github.com/webpack/karma-webpack#source-maps
*/
devtool: 'inline-source-map',
/**
* Options affecting the normal modules.
*
* See: http://webpack.github.io/docs/configuration.html#module
*/
module: {
/**
* An array of applied pre and post loaders.
*
* See: http://webpack.github.io/docs/configuration.html#module-preloaders-module-postloaders
*/
rules: [
// PRE-LOADERS
/**
* Instruments JS files with Istanbul for subsequent code coverage reporting.
* Instrument only testing sources.
*
* See: https://github.com/deepsweet/istanbul-instrumenter-loader
*/
{
test: /\.(js|ts)$/,
loader: 'istanbul-instrumenter-loader',
include: [
appConfig.srcPath,
appConfig.testPath
],
exclude: [
/\.(e2e|spec)\.ts$/,
/node_modules/
],
enforce: 'pre'
}
]
},
/**
* Add additional plugins to the compiler.
*
* See: http://webpack.github.io/docs/configuration.html#plugins
*/
plugins: [
new SourceMapDevToolPlugin({
filename: null, // if no value is provided the sourcemap is inlined
test: /\.(ts|js)($|\?)/i // process .js and .ts files only
}),
new LoaderOptionsPlugin({
test: /\.ts/i,
options: {
tslint: {
enforce: 'pre',
emitErrors: true,
failOnHint: false
}
}
}),
new DefinePlugin({
'ENV': JSON.stringify(ENV),
'HMR': false,
'process.env': {
'ENV': JSON.stringify(ENV),
'NODE_ENV': JSON.stringify(ENV),
'HMR': false,
'PORT': 3000
},
'APP_CONFIG': JSON.stringify(appConfig)
})
]
});
debugLog('Using following webpack test config:', config);
module.exports = config;