Skip to content

Commit 2226346

Browse files
author
borysn
committed
update front test for webpack 2
1 parent 70f818a commit 2226346

File tree

1 file changed

+36
-170
lines changed

1 file changed

+36
-170
lines changed

frontend/config/webpack.test.js

Lines changed: 36 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -1,196 +1,72 @@
11
/* webpack.test.js */
2-
/**
3-
* @author: @AngularClass
4-
*/
5-
2+
const webpack = require('webpack');
63
const helpers = require('./helpers');
7-
8-
/**
9-
* Webpack Plugins
10-
*/
114
const ProvidePlugin = require('webpack/lib/ProvidePlugin');
125
const DefinePlugin = require('webpack/lib/DefinePlugin');
13-
14-
/**
15-
* Webpack Constants
16-
*/
176
const ENV = process.env.ENV = process.env.NODE_ENV = 'test';
187

19-
/**
20-
* Webpack configuration
21-
*
22-
* See: http://webpack.github.io/docs/configuration.html#cli
23-
*/
248
module.exports = {
25-
26-
/**
27-
* Source map for Karma from the help of karma-sourcemap-loader & karma-webpack
28-
*
29-
* Do not change, leave as is or it wont work.
30-
* See: https://github.com/webpack/karma-webpack#source-maps
31-
*/
329
devtool: 'inline-source-map',
3310

34-
/**
35-
* Options affecting the resolving of modules.
36-
*
37-
* See: http://webpack.github.io/docs/configuration.html#resolve
38-
*/
3911
resolve: {
40-
41-
/**
42-
* An array of extensions that should be used to resolve modules.
43-
*
44-
* See: http://webpack.github.io/docs/configuration.html#resolve-extensions
45-
*/
46-
extensions: ['', '.ts', '.js'],
47-
48-
/**
49-
* Make sure root is src
50-
*/
51-
root: helpers.root('src'),
52-
12+
extensions: ['.ts', '.js'],
13+
modules: [helpers.root('src'), 'node_modules']
5314
},
5415

55-
/**
56-
* Options affecting the normal modules.
57-
*
58-
* See: http://webpack.github.io/docs/configuration.html#module
59-
*/
6016
module: {
61-
62-
/**
63-
* An array of applied pre and post loaders.
64-
*
65-
* See: http://webpack.github.io/docs/configuration.html#module-preloaders-module-postloaders
66-
*/
67-
preLoaders: [
68-
69-
/**
70-
* Tslint loader support for *.ts files
71-
*
72-
* See: https://github.com/wbuchwalter/tslint-loader
73-
*/
17+
rules: [
7418
{
7519
test: /\.ts$/,
7620
loader: 'tslint-loader',
21+
enforce: 'pre',
7722
exclude: [helpers.root('node_modules')]
7823
},
79-
80-
/**
81-
* Source map loader support for *.js files
82-
* Extracts SourceMaps for source files that as added as sourceMappingURL comment.
83-
*
84-
* See: https://github.com/webpack/source-map-loader
85-
*/
8624
{
8725
test: /\.js$/,
8826
loader: 'source-map-loader',
27+
enforce: 'pre',
8928
exclude: [
90-
// these packages have problems with their sourcemaps
91-
helpers.root('node_modules/rxjs'),
92-
helpers.root('node_modules/@angular')
93-
]}
94-
95-
],
96-
97-
/**
98-
* An array of automatically applied loaders.
99-
*
100-
* IMPORTANT: The loaders here are resolved relative to the resource which they are applied to.
101-
* This means they are not resolved relative to the configuration file.
102-
*
103-
* See: http://webpack.github.io/docs/configuration.html#module-loaders
104-
*/
105-
loaders: [
106-
107-
/**
108-
* Typescript loader support for .ts and Angular 2 async routes via .async.ts
109-
*
110-
* See: https://github.com/s-panferov/awesome-typescript-loader
111-
*/
29+
helpers.root('node_modules/rxjs'),
30+
helpers.root('node_modules/@angular')
31+
]
32+
},
11233
{
11334
test: /\.ts$/,
11435
loader: 'awesome-typescript-loader',
11536
query: {
11637
compilerOptions: {
117-
118-
// Remove TypeScript helpers to be injected
119-
// below by DefinePlugin
12038
removeComments: true
121-
12239
}
12340
},
12441
exclude: [/\.e2e\.ts$/]
12542
},
126-
127-
/**
128-
* Json loader support for *.json files.
129-
*
130-
* See: https://github.com/webpack/json-loader
131-
*/
132-
{ test: /\.json$/, loader: 'json-loader', exclude: [helpers.root('src/index.html')] },
133-
134-
/**
135-
* Raw loader support for *.css files
136-
* Returns file content as string
137-
*
138-
* See: https://github.com/webpack/raw-loader
139-
*/
140-
{ test: /\.css$/, loaders: ['to-string-loader', 'css-loader'], exclude: [helpers.root('src/index.html')] },
141-
142-
/**
143-
* Raw loader support for *.html
144-
* Returns file content as string
145-
*
146-
* See: https://github.com/webpack/raw-loader
147-
*/
148-
{ test: /\.html$/, loader: 'raw-loader', exclude: [helpers.root('src/index.html')] }
149-
150-
],
151-
152-
/**
153-
* An array of applied pre and post loaders.
154-
*
155-
* See: http://webpack.github.io/docs/configuration.html#module-preloaders-module-postloaders
156-
*/
157-
postLoaders: [
158-
159-
/**
160-
* Instruments JS files with Istanbul for subsequent code coverage reporting.
161-
* Instrument only testing sources.
162-
*
163-
* See: https://github.com/deepsweet/istanbul-instrumenter-loader
164-
*/
43+
{
44+
test: /\.json$/,
45+
loader: 'json-loader',
46+
exclude: [helpers.root('src/index.html')]
47+
},
48+
{
49+
test: /\.css$/, loaders: ['to-string-loader', 'css-loader'],
50+
exclude: [helpers.root('src/index.html')]
51+
},
52+
{
53+
test: /\.html$/,
54+
loader: 'raw-loader',
55+
exclude: [helpers.root('src/index.html')]
56+
},
16557
{
16658
test: /\.(js|ts)$/, loader: 'istanbul-instrumenter-loader',
16759
include: helpers.root('src'),
60+
enforce: 'post',
16861
exclude: [
16962
/\.(e2e|spec)\.ts$/,
17063
/node_modules/
17164
]
17265
}
173-
17466
]
17567
},
17668

177-
/**
178-
* Add additional plugins to the compiler.
179-
*
180-
* See: http://webpack.github.io/docs/configuration.html#plugins
181-
*/
18269
plugins: [
183-
184-
/**
185-
* Plugin: DefinePlugin
186-
* Description: Define free variables.
187-
* Useful for having development builds with debug logging or adding global constants.
188-
*
189-
* Environment helpers
190-
*
191-
* See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
192-
*/
193-
// NOTE: when adding more properties make sure you include them in custom-typings.d.ts
19470
new DefinePlugin({
19571
'ENV': JSON.stringify(ENV),
19672
'HMR': false,
@@ -201,31 +77,21 @@ module.exports = {
20177
}
20278
}),
20379

204-
80+
new webpack.LoaderOptionsPlugin({
81+
options: {
82+
tslint: {
83+
emitErrors: false,
84+
failOnHint: false,
85+
resourcePath: 'src'
86+
}
87+
}
88+
})
20589
],
20690

207-
/**
208-
* Static analysis linter for TypeScript advanced options configuration
209-
* Description: An extensible linter for the TypeScript language.
210-
*
211-
* See: https://github.com/wbuchwalter/tslint-loader
212-
*/
213-
tslint: {
214-
emitErrors: false,
215-
failOnHint: false,
216-
resourcePath: 'src'
217-
},
218-
219-
/**
220-
* Include polyfills or mocks for various node stuff
221-
* Description: Node configuration
222-
*
223-
* See: https://webpack.github.io/docs/configuration.html#node
224-
*/
22591
node: {
226-
global: 'window',
92+
global: true,
22793
process: false,
228-
crypto: 'empty',
94+
crypto: false,
22995
module: false,
23096
clearImmediate: false,
23197
setImmediate: false

0 commit comments

Comments
 (0)