-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathTest.js
157 lines (147 loc) · 3.73 KB
/
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
154
155
156
157
'use strict'; // eslint-disable-line
/**
* Default test configuration.
*/
const WebpackBaseConfig = require('./Base');
const webpack = require('webpack');
class WebpackTestConfig extends WebpackBaseConfig {
constructor() {
super();
const cssModulesQuery = {
modules: true,
importLoaders: 1,
localIdentName: '[name]-[local]-[hash:base64:5]'
};
this.config = {
devtool: 'inline-source-map',
entry: [
'./client.js'
],
externals: {
cheerio: 'window',
'react/addons': 'true',
'react/lib/ExecutionEnvironment': 'true',
'react/lib/ReactContext': 'true'
},
module: {
loaders: [
{
test: /\.cssmodule\.css$/,
loaders: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
query: cssModulesQuery
},
{ loader: 'postcss-loader' }
]
},
{
test: /\.cssmodule\.less$/,
loaders: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
query: cssModulesQuery
},
{ loader: 'postcss-loader' },
{ loader: 'less-loader' }
]
},
{
test: /\.cssmodule\.styl$/,
loaders: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
query: cssModulesQuery
},
{ loader: 'postcss-loader' },
{ loader: 'stylus-loader' }
]
},
{
test: /\.cssmodule\.(sass|scss)$/,
loaders: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
query: cssModulesQuery
},
{ loader: 'postcss-loader' },
{ loader: 'sass-loader' }
]
},
{
test: /^.((?!cssmodule).)*\.css$/,
loader: 'null-loader'
},
{
test: /^.((?!cssmodule).)*\.(sass|scss)$/,
loader: 'null-loader'
},
{
test: /^.((?!cssmodule).)*\.less$/,
loader: 'null-loader'
},
{
test: /^.((?!cssmodule).)*\.styl$/,
loader: 'null-loader'
},
{
test: /\.(png|jpg|gif|mp4|ogg|svg|woff|woff2)$/,
loader: 'null-loader'
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
include: [].concat(
this.includedPackages,
[
this.srcPathAbsolute,
this.testPathAbsolute
]
)
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"test"'
})
]
};
}
/**
* Set the config data.
* Will remove the devServer config value as we do not need it in test environments
* This function will always return a new config
* @param {Object} data Keys to assign
* @return {Object}
*/
set config(data) {
const baseSettings = this.defaultSettings;
delete baseSettings.devServer;
this._config = Object.assign({}, baseSettings, data);
return this._config;
}
/**
* Get the global config
* @param {Object} config Final webpack config
*/
get config() {
return super.config;
}
/**
* Get the environment name
* @return {String} The current environment
*/
get env() {
return 'test';
}
}
module.exports = WebpackTestConfig;