-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathwebpack.config.js
263 lines (234 loc) · 7.92 KB
/
webpack.config.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
var path = require('path');
var webpack = require('webpack');
var lodash = require('lodash');
module.exports = function makeConfig(grunt) {
grunt.option = grunt.option || function() {
return undefined;
};
var appConfigPath = path.join(process.cwd(), 'superdesk.config.js');
if (process.env.SUPERDESK_CONFIG) {
appConfigPath = path.join(process.cwd(), process.env.SUPERDESK_CONFIG);
}
if (grunt.option('config')) {
appConfigPath = path.join(process.cwd(), grunt.option('config'));
}
const sdConfig = lodash.defaultsDeep(require(appConfigPath)(grunt), getDefaults(grunt));
return {
entry: [path.join(__dirname, 'index')],
devtool: 'inline-source-map', //just do inline source maps instead of the default
output: {
path: path.join(process.cwd(), 'dist'),
filename: 'app.bundle.js',
},
resolve: {
modules: [
__dirname,
path.join(__dirname, 'client'),
path.join(__dirname, 'node_modules/superdesk-core'),
path.join(__dirname, 'node_modules/superdesk-core/scripts'),
path.join(__dirname, 'node_modules/superdesk-core/styles/sass'),
path.join(__dirname, 'node_modules/superdesk-core/node_modules'),
'node_modules'
],
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
alias: {
images: path.resolve(__dirname, 'node_modules/superdesk-core/images'),
'angular-embedly': path.resolve(
__dirname,
'node_modules/angular-embedly/em-minified/angular-embedly.min'
),
'jquery-gridster': path.resolve(
__dirname,
'node_modules/gridster/dist/jquery.gridster.min'
),
'rangy-saverestore': path.resolve(
__dirname,
'node_modules/rangy/lib/rangy-selectionsaverestore'
),
}
},
module: {
rules: [
{
test: /\.(ts|tsx)?$/,
exclude: /node_modules\/(?!(superdesk-core)\/).*/,
loader: 'ts-loader',
options: {
transpileOnly: true
}
},
{
test: /\.(js|jsx)?$/,
exclude: /node_modules\/(?!(superdesk-core)\/).*/,
loader: 'ts-loader',
options: {
transpileOnly: true
}
},
{
test: /\.html$/,
loader: 'html-loader'
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
{
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
'sass-loader'
]
},
{
test: /\.json$/,
use: ['json-loader']
},
{
test: /\.(png|gif|jpeg|jpg|woff|woff2|eot|ttf|svg)(\?.*$|$)/,
loader: 'file-loader'
}
],
},
externals: {
cheerio: 'window',
'react/addons': true,
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': true
},
// Define mock gettext ('required when running unit_tests for planning)
plugins: [
new webpack.DefinePlugin({gettext: 'function gettext(msg) { return msg; }'}),
new webpack.ProvidePlugin({
$: 'jquery',
'window.$': 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
moment: 'moment',
// MediumEditor needs to be globally available, because
// its plugins will not be able to find it otherwise.
MediumEditor: 'medium-editor',
}),
new webpack.DefinePlugin({
__SUPERDESK_CONFIG__: JSON.stringify(sdConfig),
}),
],
};
}
// getDefaults returns the default configuration for the app
function getDefaults(grunt) {
var version;
try {
version = require('git-rev-sync').short('..');
} catch (err) {
// pass
}
return {
// application version
version: version || grunt.file && grunt.file.readJSON(path.join(__dirname, 'package.json')).version,
// raven settings
raven: {
dsn: process.env.SUPERDESK_RAVEN_DSN || '',
},
// backend server URLs configuration
server: {
url: grunt.option('server') || process.env.SUPERDESK_URL || 'http://localhost:5000/api',
ws: grunt.option('ws') || process.env.SUPERDESK_WS_URL || 'ws://0.0.0.0:5100',
},
// iframely settings
iframely: {
key: process.env.IFRAMELY_KEY || '',
},
// google settings
google: {
key: process.env.GOOGLE_KEY || '',
},
// settings for various analytics
analytics: {
piwik: {
url: process.env.PIWIK_URL || '',
id: process.env.PIWIK_SITE_ID || '',
},
ga: {
id: process.env.TRACKING_ID || '',
},
},
// editor configuration
editor: {
// if true, the editor will not have a toolbar
disableEditorToolbar: grunt.option('disableEditorToolbar'),
},
// default timezone for the app
defaultTimezone: grunt.option('defaultTimezone') || 'Europe/London',
// model date and time formats
model: {
dateformat: 'DD/MM/YYYY',
timeformat: 'HH:mm:ss',
},
// view formats for datepickers/timepickers
view: {
dateformat: process.env.VIEW_DATE_FORMAT || 'DD/MM/YYYY',
timeformat: process.env.VIEW_TIME_FORMAT || 'HH:mm',
},
// if environment name is not set
isTestEnvironment: !!grunt.option('environmentName') || !!process.env.SUPERDESK_ENVIRONMENT,
// environment name
environmentName: grunt.option('environmentName') || process.env.SUPERDESK_ENVIRONMENT,
// route to be redirected to from '/'
defaultRoute: '/workspace',
// override language translations
langOverride: {},
// app features
features: {
// tansa spellchecker
useTansaProofing: false,
// replace editor2
onlyEditor3: false,
},
// tansa config
tansa: {
profile: {
nb: 1,
nn: 2,
},
},
// workspace defaults
workspace: {
ingest: false,
content: false,
tasks: false,
analytics: true,
},
// ingest defaults
ingest: {
PROVIDER_DASHBOARD_DEFAULTS: {
show_log_messages: true,
show_ingest_count: true,
show_time: true,
log_messages: 'error',
show_status: true,
},
DEFAULT_SCHEDULE: {minutes: 5, seconds: 0},
DEFAULT_IDLE_TIME: {hours: 0, minutes: 0},
},
// list of languages available in user profile
profileLanguages: [
'en',
'el',
'en_GB',
'es',
'da',
'ar',
'de_DE',
'ru_RU',
'nb',
'uk_UA',
'pt_BR',
'pl',
],
};
}