This repository has been archived by the owner on Jan 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.test.js
153 lines (148 loc) · 4.54 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
const helpers = require('./helpers');
const webpack = require('webpack');
const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin');
module.exports = {
mode: 'development',
entry: {
main: './test-entry.js'
},
resolve: {
extensions: ['.ts', '.js'],
modules: [
helpers.root('src'),
helpers.root('node_modules')
]
},
devtool: 'inline-source-map',
output: {
path: helpers.root('dist'),
filename: '[name].js',
sourceMapFilename: '[name].map',
chunkFilename: '[id].chunk.js'
},
module: {
// configuration regarding modules
rules: [
{
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader',
exclude: [
helpers.root('node_modules/rxjs'),
helpers.root('node_modules/@angular')
]
},
// rules for modules (configure loaders, parser options, etc.)
{
test: /\.ts$/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
configFile: helpers.root('tsconfig.json')
}
},
{
loader: 'angular2-template-loader'
}
],
exclude: [/\.e2e\.ts$/]
},
{
test: /[\/\\]@angular[\/\\]core[\/\\].+\.js$/,
parser: { system: true },
},
{
test: /\.less$/,
use: [
'style-loader',
'css-loader',
'semantic-ui-less-module-loader'
],
include: [/[\/\\]node_modules[\/\\]semantic-ui-less[\/\\]/]
},
{
test: /.less$/,
use: [
'to-string-loader',
'css-loader',
'less-loader'
],
include: [/src[\/\\]/]
},
{
test: /.less$/,
use: [
'style-loader',
'css-loader',
'less-loader'
],
exclude: [
/node_modules/,
/src[\/\\]/]
},
{
test: /\.html$/,
use: 'html-loader',
exclude: [helpers.root('src/index.html')]
}
]
},
plugins: [
/**
* Plugin: ContextReplacementPlugin
* Description: Provides context to Angular's use of System.import
*
* See: https://webpack.github.io/docs/list-of-plugins.html#contextreplacementplugin
* See: https://github.com/angular/angular/issues/11580
*/
new ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/@angular(\\|\/)core(\\|\/)f?esm5/,
helpers.root('src') // location of your src
),
new webpack.LoaderOptionsPlugin({
// switch loader to debug mode
debug: true,
options: {
// Static analysis linter for TypeScript advanced options configuration
// Description: An extensible linter for the TypeScript language.
//
// See: https://github.com/wbuchwalter/tslint-loader
tslint: {
emitErrors: false,
failOnHint: false,
resourcePath: 'src'
}
}
})
],
// Webpack Development Server configuration
// Description: The webpack-dev-server is a little node.js Express server.
// The server emits information about the compilation state to the client,
// which reacts to those events.
//
// See: https://webpack.github.io/docs/webpack-dev-server.html
devServer: {
port: 3000,
host: 'localhost',
historyApiFallback: true,
watchOptions: {
aggregateTimeout: 300,
poll: 1000
}
},
// Disable performance hints
performance: {
hints: false
},
node: {
global: true,
crypto: 'empty',
process: true,
module: false,
clearImmediate: false,
setImmediate: false
}
};