1 | exports["setup"] =
|
2 | (function(modules) {
|
3 |
|
4 | var installedModules = {};
|
5 |
|
6 |
|
7 | function __webpack_require__(moduleId) {
|
8 |
|
9 |
|
10 | if(installedModules[moduleId]) {
|
11 | return installedModules[moduleId].exports;
|
12 | }
|
13 |
|
14 | var module = installedModules[moduleId] = {
|
15 | i: moduleId,
|
16 | l: false,
|
17 | exports: {}
|
18 | };
|
19 |
|
20 |
|
21 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
22 |
|
23 |
|
24 | module.l = true;
|
25 |
|
26 |
|
27 | return module.exports;
|
28 | }
|
29 |
|
30 |
|
31 |
|
32 | __webpack_require__.m = modules;
|
33 |
|
34 |
|
35 | __webpack_require__.c = installedModules;
|
36 |
|
37 |
|
38 | __webpack_require__.i = function(value) { return value; };
|
39 |
|
40 |
|
41 | __webpack_require__.d = function(exports, name, getter) {
|
42 | if(!__webpack_require__.o(exports, name)) {
|
43 | Object.defineProperty(exports, name, {
|
44 | configurable: false,
|
45 | enumerable: true,
|
46 | get: getter
|
47 | /******/ });
|
48 | /******/ }
|
49 | /******/ };
|
50 | /******/
|
51 | /******/ // getDefaultExport function for compatibility with non-harmony modules
|
52 | /******/ __webpack_require__.n = function(module) {
|
53 | var getter = module && module.__esModule ?
|
54 | function getDefault() { return module['default']; } :
|
55 | function getModuleExports() { return module; };
|
56 | __webpack_require__.d(getter, 'a', getter);
|
57 | return getter;
|
58 | };
|
59 |
|
60 |
|
61 | __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
62 |
|
63 |
|
64 | __webpack_require__.p = "";
|
65 |
|
66 |
|
67 | return __webpack_require__(__webpack_require__.s = 4);
|
68 | })
|
69 |
|
70 | ([
|
71 |
|
72 | (function(module, exports) {
|
73 |
|
74 | module.exports = require("path");
|
75 |
|
76 | }),
|
77 |
|
78 | (function(module, exports) {
|
79 |
|
80 | module.exports = require("preconditions");
|
81 |
|
82 | }),
|
83 |
|
84 | (function(module, exports) {
|
85 |
|
86 | module.exports = require("webpack");
|
87 |
|
88 | }),
|
89 |
|
90 | (function(module, exports, __webpack_require__) {
|
91 |
|
92 | "use strict";
|
93 |
|
94 |
|
95 | Object.defineProperty(exports, "__esModule", {
|
96 | value: true
|
97 | });
|
98 |
|
99 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
100 |
|
101 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
102 |
|
103 | var _path = __webpack_require__(0);
|
104 |
|
105 | var _path2 = _interopRequireDefault(_path);
|
106 |
|
107 | var _preconditions = __webpack_require__(1);
|
108 |
|
109 | var _preconditions2 = _interopRequireDefault(_preconditions);
|
110 |
|
111 | var _webpack = __webpack_require__(2);
|
112 |
|
113 | var _webpack2 = _interopRequireDefault(_webpack);
|
114 |
|
115 | var _WebpackConfigurationFactory = __webpack_require__(5);
|
116 |
|
117 | var _WebpackConfigurationFactory2 = _interopRequireDefault(_WebpackConfigurationFactory);
|
118 |
|
119 | var _webpackDevServer = __webpack_require__(12);
|
120 |
|
121 | var _webpackDevServer2 = _interopRequireDefault(_webpackDevServer);
|
122 |
|
123 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
124 |
|
125 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
126 |
|
127 | var UniversalWebApplicationSetup = function () {
|
128 | _createClass(UniversalWebApplicationSetup, null, [{
|
129 | key: 'create',
|
130 | value: function create(options) {
|
131 | return new UniversalWebApplicationSetup(options);
|
132 | }
|
133 | }]);
|
134 |
|
135 | function UniversalWebApplicationSetup(options) {
|
136 | _classCallCheck(this, UniversalWebApplicationSetup);
|
137 |
|
138 | var pc = _preconditions2.default.instance(options);
|
139 | pc.shouldBeDefined('name', 'Please provide the name of the application.');
|
140 | pc.shouldBeDefined('host', 'Please provide the host of the application.');
|
141 | pc.shouldBeDefined('port', 'Please provide the port of the application.');
|
142 | pc.shouldBeDefined('pingPort', 'Please provide the ping port of the application.');
|
143 | pc.shouldBeDefined('rootProjectPath', 'Please provide the rootProjectPath.');
|
144 | pc.shouldBeDefined('rootDeploymentPath', 'Please provide the rootDeploymentPath.');
|
145 | pc.shouldBeDefined('environment', 'Please provide the environment.');
|
146 |
|
147 | console.log('Application is initializing - ', options.name);
|
148 |
|
149 | this._options = options;
|
150 |
|
151 | if (this._options.modules == null || typeof this._options.modules === 'undefined') {
|
152 | this._options.modules = [];
|
153 | } else {
|
154 | if (!(this._options.modules instanceof Array)) {
|
155 | this._options.modules = [];
|
156 | console.warn('[COMPILER] Omitting modules entry. You should put the modules folder in an array.');
|
157 | }
|
158 | }
|
159 |
|
160 | this._applicationName = options.name;
|
161 | this._applicationHost = options.host;
|
162 |
|
163 | var rootProjectPath = options.rootProjectPath;
|
164 | var rootApplicationPath = _path2.default.join(options.rootProjectPath, 'applications', options.name);
|
165 |
|
166 | var rootDeploymentPath = options.rootDeploymentPath;
|
167 | var rootDeploymentApplicationPath = _path2.default.join(options.rootDeploymentPath, 'applications', options.name);
|
168 |
|
169 | console.log('==> rootProjectPath: ', rootProjectPath);
|
170 | console.log('==> rootApplicationPath: ', rootApplicationPath);
|
171 | console.log('==> rootDeploymentPath: ', rootDeploymentPath);
|
172 | console.log('==> rootDeploymentApplicationPath: ', rootDeploymentApplicationPath);
|
173 | console.log('==> supportedLocales: ', options.locales);
|
174 | console.log('==> modules: ', options.modules);
|
175 |
|
176 | this._rootProjectPath = rootProjectPath;
|
177 | this._rootApplicationPath = rootApplicationPath;
|
178 | this._rootDeploymentPath = rootDeploymentPath;
|
179 | this._rootDeploymentApplicationPath = rootDeploymentApplicationPath;
|
180 |
|
181 | var projectConfigurationOptions = {
|
182 | applicationName: options.name,
|
183 | applicationHost: options.host,
|
184 | rootProjectPath: rootProjectPath,
|
185 | rootApplicationPath: rootApplicationPath,
|
186 | rootDeploymentPath: rootDeploymentPath,
|
187 | rootDeploymentApplicationPath: rootDeploymentApplicationPath,
|
188 | environment: options.environment,
|
189 | locales: options.locales,
|
190 | port: options.port,
|
191 | pingPort: options.pingPort,
|
192 | modules: options.modules
|
193 | };
|
194 |
|
195 | var webpackConfigurationOptions = _extends({
|
196 | devPort: options.devPort
|
197 | }, projectConfigurationOptions);
|
198 | console.log('Building webpack configurations, we will put on some commonly used plugin & configuration.');
|
199 | this._webpackConfigurationFactory = new _WebpackConfigurationFactory2.default(webpackConfigurationOptions);
|
200 | this._webpackConfiguration = this._webpackConfigurationFactory.createWebpackConfiguration(webpackConfigurationOptions);
|
201 | this._compiler = this._createWebpackCompiler(this._webpackConfiguration);
|
202 | }
|
203 |
|
204 | _createClass(UniversalWebApplicationSetup, [{
|
205 | key: 'run',
|
206 | value: function run() {
|
207 | var _this = this;
|
208 |
|
209 | if (this._options.environment === 'development') {
|
210 | console.log('[COMPILER] Initiating server compilation');
|
211 | var serverConfiguration = this._webpackConfiguration[0];
|
212 | var serverCompiler = this._createWebpackCompiler(serverConfiguration);
|
213 | serverCompiler.watch({
|
214 | aggregateTimeout: 300,
|
215 | poll: true
|
216 | }, function (err, stats) {
|
217 | if (err) console.error(err);
|
218 |
|
219 | console.log(stats.compilation.errors.toString({ colors: true }));
|
220 | console.log(stats.compilation.warnings.toString({ colors: true }));
|
221 | console.log('[COMPILER] Server compilation finished. Watching for server file changes.');
|
222 | });
|
223 |
|
224 | console.log('[COMPILER] Initiating client compilation using webpack-dev-server');
|
225 | var clientConfiguration = this._webpackConfiguration[1];
|
226 | var clientCompiler = this._createWebpackCompiler(clientConfiguration);
|
227 | var clientDevServer = new _webpackDevServer2.default(clientCompiler, {
|
228 | contentBase: _path2.default.join(this._rootApplicationPath, 'build'),
|
229 | hot: true,
|
230 | filename: 'main.js',
|
231 | proxy: {
|
232 | '**': 'http://localhost:' + this._options.port
|
233 | },
|
234 | watchOptions: {
|
235 | aggregateTimeout: 300,
|
236 | poll: 1000
|
237 | },
|
238 | stats: {
|
239 | color: true
|
240 | },
|
241 | publicPath: '/assets',
|
242 | disableHostCheck: true
|
243 | });
|
244 | clientDevServer.listen(this._options.devPort, function (err) {
|
245 | if (err) {
|
246 | console.err('[ERROR]: ', err, err.stack);
|
247 | } else {
|
248 | console.log('\n[COMPILER] webpack-dev-server is listening at port ' + _this._options.devPort);
|
249 | console.log('[COMPILER] Client compilation finished. Watching for client file changes.');
|
250 | }
|
251 | });
|
252 | } else {
|
253 | console.log('[COMPILER] Initiating compilation.');
|
254 | this._compiler = this._createWebpackCompiler(this._webpackConfiguration);
|
255 | this._compiler.run(function (err, stats) {
|
256 | if (err) console.error(err);
|
257 | console.log(stats.toString({ colors: true }));
|
258 | console.log('[COMPILER] Compilation finished.');
|
259 | });
|
260 | }
|
261 | }
|
262 | }, {
|
263 | key: '_createWebpackCompiler',
|
264 | value: function _createWebpackCompiler(configuration) {
|
265 | var compiler = (0, _webpack2.default)(configuration);
|
266 | return compiler;
|
267 | }
|
268 | }]);
|
269 |
|
270 | return UniversalWebApplicationSetup;
|
271 | }();
|
272 |
|
273 | exports.default = UniversalWebApplicationSetup;
|
274 | module.exports = exports['default'];
|
275 |
|
276 | }),
|
277 |
|
278 | (function(module, exports, __webpack_require__) {
|
279 |
|
280 | "use strict";
|
281 |
|
282 |
|
283 | Object.defineProperty(exports, "__esModule", {
|
284 | value: true
|
285 | });
|
286 |
|
287 | var _UniversalWebApplicationSetup = __webpack_require__(3);
|
288 |
|
289 | var _UniversalWebApplicationSetup2 = _interopRequireDefault(_UniversalWebApplicationSetup);
|
290 |
|
291 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
292 |
|
293 | exports.default = {
|
294 | CatelaApplicationSetup: _UniversalWebApplicationSetup2.default
|
295 | };
|
296 | module.exports = exports['default'];
|
297 |
|
298 | }),
|
299 |
|
300 | (function(module, exports, __webpack_require__) {
|
301 |
|
302 | "use strict";
|
303 |
|
304 |
|
305 | Object.defineProperty(exports, "__esModule", {
|
306 | value: true
|
307 | });
|
308 |
|
309 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
310 |
|
311 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
312 |
|
313 |
|
314 |
|
315 | var _assetsWebpackPlugin = __webpack_require__(6);
|
316 |
|
317 | var _assetsWebpackPlugin2 = _interopRequireDefault(_assetsWebpackPlugin);
|
318 |
|
319 | var _chalk = __webpack_require__(7);
|
320 |
|
321 | var _chalk2 = _interopRequireDefault(_chalk);
|
322 |
|
323 | var _extractTextWebpackPlugin = __webpack_require__(8);
|
324 |
|
325 | var _extractTextWebpackPlugin2 = _interopRequireDefault(_extractTextWebpackPlugin);
|
326 |
|
327 | var _fs = __webpack_require__(9);
|
328 |
|
329 | var _fs2 = _interopRequireDefault(_fs);
|
330 |
|
331 | var _path = __webpack_require__(0);
|
332 |
|
333 | var _path2 = _interopRequireDefault(_path);
|
334 |
|
335 | var _preconditions = __webpack_require__(1);
|
336 |
|
337 | var _preconditions2 = _interopRequireDefault(_preconditions);
|
338 |
|
339 | var _progressBarWebpackPlugin = __webpack_require__(10);
|
340 |
|
341 | var _progressBarWebpackPlugin2 = _interopRequireDefault(_progressBarWebpackPlugin);
|
342 |
|
343 | var _statsWebpackPlugin = __webpack_require__(11);
|
344 |
|
345 | var _statsWebpackPlugin2 = _interopRequireDefault(_statsWebpackPlugin);
|
346 |
|
347 | var _webpack = __webpack_require__(2);
|
348 |
|
349 | var _webpack2 = _interopRequireDefault(_webpack);
|
350 |
|
351 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
352 |
|
353 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
354 |
|
355 |
|
356 | var progressBarPlugin = new _progressBarWebpackPlugin2.default({
|
357 | format: ' build [:bar] ' + _chalk2.default.green.bold(':percent') + ' (:elapsed seconds)',
|
358 | clear: false
|
359 | });
|
360 |
|
361 | var WebpackConfigurationFactory = function () {
|
362 | function WebpackConfigurationFactory(options) {
|
363 | _classCallCheck(this, WebpackConfigurationFactory);
|
364 |
|
365 | var pc = _preconditions2.default.instance(options);
|
366 | pc.shouldBeDefined('applicationName', 'applicationName is required.');
|
367 | pc.shouldBeDefined('applicationHost', 'applicationHost is required.');
|
368 | pc.shouldBeDefined('rootProjectPath', 'rootProjectPath is required.');
|
369 | pc.shouldBeDefined('rootApplicationPath', 'rootApplicationPath is required.');
|
370 | pc.shouldBeDefined('rootDeploymentPath', 'rootDeploymentPath is required.');
|
371 | pc.shouldBeDefined('rootDeploymentApplicationPath', 'rootDeploymentApplicationPath is required.');
|
372 | pc.shouldBeDefined('environment', 'environment is required.');
|
373 | pc.shouldBeDefined('locales', 'locales is required.');
|
374 | pc.shouldBeDefined('modules', 'modules is required');
|
375 |
|
376 | this._options = options;
|
377 | this._applicationHost = options.applicationHost;
|
378 | this._applicationName = options.applicationName;
|
379 | this._rootProjectPath = options.rootProjectPath;
|
380 | this._rootApplicationPath = options.rootApplicationPath;
|
381 | this._rootDeploymentPath = options.rootDeploymentPath;
|
382 | this._rootDeploymentApplicationPath = options.rootDeploymentApplicationPath;
|
383 | this._environment = options.environment;
|
384 | }
|
385 |
|
386 | _createClass(WebpackConfigurationFactory, [{
|
387 | key: 'createWebpackConfiguration',
|
388 | value: function createWebpackConfiguration() {
|
389 | var client = this._createClientWebpackConfiguration();
|
390 | var server = this._createServerWebpackConfiguration();
|
391 | var config = [server, client];
|
392 | return config;
|
393 | }
|
394 | }, {
|
395 | key: '_createServerWebpackConfiguration',
|
396 | value: function _createServerWebpackConfiguration() {
|
397 | var options = this._options;
|
398 | var entry = this._buildServerEntry(options);
|
399 | var output = this._buildServerOutput(options);
|
400 | var plugins = this._buildServerPlugins(options);
|
401 | var common = this._buildCommon();
|
402 |
|
403 | var externalNodeModules = {};
|
404 | var nodeModulePath = _path2.default.join(this._rootProjectPath, 'node_modules');
|
405 | _fs2.default.readdirSync(nodeModulePath).filter(function (x) {
|
406 | return ['.bin'].indexOf(x) === -1;
|
407 | }).forEach(function (mod) {
|
408 | if (mod !== 'react-toolbox') {
|
409 | externalNodeModules[mod] = 'commonjs ' + mod;
|
410 | }
|
411 | });
|
412 |
|
413 | return _extends({
|
414 | name: 'server'
|
415 | }, common, {
|
416 | entry: entry,
|
417 | output: output,
|
418 | plugins: plugins,
|
419 | target: 'node',
|
420 | devtool: 'sourcemap',
|
421 | externals: externalNodeModules
|
422 | });
|
423 | }
|
424 | }, {
|
425 | key: '_createClientWebpackConfiguration',
|
426 | value: function _createClientWebpackConfiguration() {
|
427 | var options = this._options;
|
428 | var entry = this._buildClientEntry(options);
|
429 | var output = this._buildClientOutput(options);
|
430 | var plugins = this._buildClientPlugins(options);
|
431 | var common = this._buildCommon();
|
432 |
|
433 | return _extends({
|
434 | name: 'client'
|
435 | }, common, {
|
436 | entry: entry,
|
437 | output: output,
|
438 | plugins: plugins,
|
439 | devtool: 'sourcemap'
|
440 | });
|
441 | }
|
442 | }, {
|
443 | key: '_buildCommon',
|
444 | value: function _buildCommon() {
|
445 | var _this = this;
|
446 |
|
447 | var options = this._options;
|
448 | var loaders = this._buildLoaders(options);
|
449 | var applicationNamespace = _path2.default.join(this._rootProjectPath, 'applications', options.applicationName);
|
450 | var modulesDirectories = ['node_modules', applicationNamespace];
|
451 | this._options.modules.forEach(function (m) {
|
452 | var moduleNamespace = _path2.default.join(_this._rootProjectPath, m);
|
453 | modulesDirectories.push(moduleNamespace);
|
454 | });
|
455 | var config = {
|
456 | resolve: {
|
457 | modules: modulesDirectories,
|
458 | extensions: ['*', '.js', '.jsx', '.scss', '.css', '.ts', '.tsx']
|
459 | },
|
460 | module: _extends({}, loaders)
|
461 | };
|
462 | return config;
|
463 | }
|
464 | }, {
|
465 | key: '_buildServerEntry',
|
466 | value: function _buildServerEntry(options) {
|
467 | var entry = {
|
468 | server: _path2.default.join(this._rootApplicationPath, 'server.jsx')
|
469 | };
|
470 | return entry;
|
471 | }
|
472 | }, {
|
473 | key: '_buildClientEntry',
|
474 | value: function _buildClientEntry(options) {
|
475 | var environment = this._options.environment;
|
476 | var clientEntry = [];
|
477 | if (environment === 'development') {
|
478 | clientEntry.push('react-hot-loader/patch');
|
479 | clientEntry.push('webpack-dev-server/client?http://localhost:' + this._options.devPort + '/');
|
480 | }
|
481 | clientEntry.push(_path2.default.join(this._rootApplicationPath, 'client.jsx'));
|
482 | var entry = {
|
483 | libs: ['react', 'react-dom', 'react-router'],
|
484 | client: clientEntry
|
485 | };
|
486 | return entry;
|
487 | }
|
488 | }, {
|
489 | key: '_buildClientOutput',
|
490 | value: function _buildClientOutput(options) {
|
491 | |
492 |
|
493 |
|
494 |
|
495 | var output = {
|
496 | path: _path2.default.join(this._rootApplicationPath, 'build', this._environment, 'client'),
|
497 | publicPath: this._applicationHost + '/assets/',
|
498 | filename: 'main.js',
|
499 | chunkFilename: '[id].[name].js',
|
500 | sourceMapFilename: '[file].map'
|
501 | };
|
502 |
|
503 | return output;
|
504 | }
|
505 | }, {
|
506 | key: '_buildServerOutput',
|
507 | value: function _buildServerOutput(options) {
|
508 | |
509 |
|
510 |
|
511 |
|
512 | var output = {
|
513 | path: _path2.default.join(this._rootApplicationPath, 'build', this._environment, 'server'),
|
514 | publicPath: this._applicationHost + '/assets/',
|
515 | filename: 'main.js',
|
516 | chunkFilename: '[id].[name].js',
|
517 | sourceMapFilename: '__dev/assets/server/debugging/[file].map'
|
518 | };
|
519 |
|
520 | return output;
|
521 | }
|
522 | }, {
|
523 | key: '_buildLoaders',
|
524 | value: function _buildLoaders(options) {
|
525 | var loaders = {
|
526 | 'jsx': this._environment === 'development'
|
527 | ? ['react-hot-loader/webpack', 'babel-loader?compact=false'] : ['babel-loader?compact=false'],
|
528 | 'js': 'babel-loader?compact=false',
|
529 | 'tsx': 'ts-loader',
|
530 | 'ts': 'ts-loader',
|
531 | 'json': 'json-loader',
|
532 | 'json5': 'json5-loader',
|
533 | 'txt': 'raw-loader',
|
534 | 'png|jpg|jpeg|gif|svg': 'url-loader?limit=10000',
|
535 | 'otf|woff|woff2': 'url-loader?limit=100000',
|
536 | 'ttf|eot': 'file-loader',
|
537 | 'wav|mp3': 'file-loader',
|
538 | 'html': 'html-loader',
|
539 | 'md|markdown': ['html-loader', 'markdown-loader']
|
540 | };
|
541 |
|
542 | var cssLoader = 'css-loader?module&localIdentName=[name]-[local]-[hash:base64:5]';
|
543 |
|
544 | var stylesheetLoaders = {
|
545 | 'css': cssLoader,
|
546 | 'less': [cssLoader, 'less-loader'],
|
547 | 'styl': [cssLoader, 'stylus-loader'],
|
548 | 'scss|sass': [cssLoader, 'sass-loader']
|
549 | };
|
550 |
|
551 | Object.keys(stylesheetLoaders).forEach(function (ext) {
|
552 | var stylesheetLoader = stylesheetLoaders[ext];
|
553 | if (Array.isArray(stylesheetLoader)) {
|
554 | stylesheetLoader = stylesheetLoader.join('!');
|
555 | }
|
556 | stylesheetLoaders[ext] = _extractTextWebpackPlugin2.default.extract({
|
557 | fallback: 'style-loader',
|
558 | use: stylesheetLoader
|
559 | });
|
560 | });
|
561 |
|
562 | var resultLoaders = [].concat(this._loadersByExtension(loaders)).concat(this._loadersByExtension(stylesheetLoaders));
|
563 |
|
564 | return {
|
565 | loaders: resultLoaders
|
566 | };
|
567 | }
|
568 | }, {
|
569 | key: '_buildServerPlugins',
|
570 | value: function _buildServerPlugins(options) {
|
571 | var plugins = [];
|
572 |
|
573 |
|
574 | plugins.push(progressBarPlugin);
|
575 | plugins.push(new _statsWebpackPlugin2.default('stats.json', {
|
576 | chunkModules: true
|
577 | }));
|
578 | plugins.push(new _webpack2.default.DefinePlugin({
|
579 | '__PROJECT__': JSON.stringify(this._options),
|
580 | '__SERVER__': true,
|
581 | '__CLIENT__': false
|
582 | }));
|
583 | plugins.push(new _extractTextWebpackPlugin2.default('styles.css'));
|
584 | plugins.push(new _assetsWebpackPlugin2.default({
|
585 | prettyPrint: true,
|
586 | path: _path2.default.join(this._rootApplicationPath, 'build', this._environment, 'server'),
|
587 | update: true
|
588 | }));
|
589 | plugins.push(new _webpack2.default.WatchIgnorePlugin([/\.d\.ts$/]));
|
590 | return plugins;
|
591 | }
|
592 | }, {
|
593 | key: '_buildClientPlugins',
|
594 | value: function _buildClientPlugins(options) {
|
595 | var project = {
|
596 | applicationName: this._options.applicationName,
|
597 | applicationHost: this._options.applicationHost,
|
598 | environment: this._options.environment,
|
599 | locales: this._options.locales
|
600 | };
|
601 | var plugins = [];
|
602 |
|
603 | plugins.push(progressBarPlugin);
|
604 |
|
605 | if (this._options.environment === 'development') {
|
606 | plugins.push(new _webpack2.default.PrefetchPlugin('react'));
|
607 | plugins.push(new _webpack2.default.PrefetchPlugin('react-router'));
|
608 | plugins.push(new _webpack2.default.PrefetchPlugin('react-dom/lib/ReactComponentBrowserEnvironment'));
|
609 | plugins.push(new _webpack2.default.HotModuleReplacementPlugin());
|
610 | }
|
611 |
|
612 | plugins.push(new _statsWebpackPlugin2.default('stats.json', {
|
613 | chunkModules: true
|
614 | }));
|
615 |
|
616 | plugins.push(new _webpack2.default.optimize.CommonsChunkPlugin({
|
617 | name: 'libs',
|
618 | filename: 'commons.js',
|
619 | minChunks: 0
|
620 | }));
|
621 |
|
622 | if (this._options.environment !== 'development') {
|
623 | plugins.push(new _webpack2.default.optimize.UglifyJsPlugin({ compressor: { warnings: false } }));
|
624 | }
|
625 |
|
626 | plugins.push(new _webpack2.default.DefinePlugin({
|
627 | 'process.env': {
|
628 | 'NODE_ENV': JSON.stringify(this._environment)
|
629 | },
|
630 | '__SERVER__': false,
|
631 | '__CLIENT__': true,
|
632 | '__PROJECT__': JSON.stringify(project)
|
633 | }));
|
634 | plugins.push(new _webpack2.default.NoEmitOnErrorsPlugin());
|
635 | plugins.push(new _extractTextWebpackPlugin2.default('styles.css'));
|
636 | plugins.push(new _assetsWebpackPlugin2.default({
|
637 | prettyPrint: true,
|
638 | path: _path2.default.join(this._rootApplicationPath, 'build', this._environment, 'client'),
|
639 | update: true
|
640 | }));
|
641 | plugins.push(new _webpack2.default.WatchIgnorePlugin([/\.d\.ts$/]));
|
642 | return plugins;
|
643 | }
|
644 | }, {
|
645 | key: '_extsToRegExp',
|
646 | value: function _extsToRegExp(exts) {
|
647 | return new RegExp('\\.(' + exts.map(function (ext) {
|
648 | return ext.replace(/\./g, '\\.');
|
649 | }).join('|') + ')(\\?.*)?$');
|
650 | }
|
651 | }, {
|
652 | key: '_loadersByExtension',
|
653 | value: function _loadersByExtension(obj) {
|
654 | var self = this;
|
655 | var loaders = [];
|
656 | Object.keys(obj).forEach(function (key) {
|
657 | var exts = key.split('|');
|
658 | var value = obj[key];
|
659 | var entry;
|
660 | if (exts.indexOf('js') >= 0) {
|
661 | entry = {
|
662 | exclude: [/node_modules/],
|
663 | options: {
|
664 | ignore: [/node_modules/]
|
665 | },
|
666 | test: self._extsToRegExp(exts)
|
667 | };
|
668 | } else {
|
669 | entry = {
|
670 | test: self._extsToRegExp(exts)
|
671 | };
|
672 | }
|
673 |
|
674 | if (Array.isArray(value)) {
|
675 | entry.loaders = value;
|
676 | } else if (typeof value === 'string') {
|
677 | entry.loader = value;
|
678 | } else {
|
679 | Object.keys(value).forEach(function (valueKey) {
|
680 | entry[valueKey] = value[valueKey];
|
681 | });
|
682 | }
|
683 | loaders.push(entry);
|
684 | });
|
685 | return loaders;
|
686 | }
|
687 | }]);
|
688 |
|
689 | return WebpackConfigurationFactory;
|
690 | }();
|
691 |
|
692 | exports.default = WebpackConfigurationFactory;
|
693 | module.exports = exports['default'];
|
694 |
|
695 | }),
|
696 |
|
697 | (function(module, exports) {
|
698 |
|
699 | module.exports = require("assets-webpack-plugin");
|
700 |
|
701 | }),
|
702 |
|
703 | (function(module, exports) {
|
704 |
|
705 | module.exports = require("chalk");
|
706 |
|
707 | }),
|
708 |
|
709 | (function(module, exports) {
|
710 |
|
711 | module.exports = require("extract-text-webpack-plugin");
|
712 |
|
713 | }),
|
714 |
|
715 | (function(module, exports) {
|
716 |
|
717 | module.exports = require("fs");
|
718 |
|
719 | }),
|
720 |
|
721 | (function(module, exports) {
|
722 |
|
723 | module.exports = require("progress-bar-webpack-plugin");
|
724 |
|
725 | }),
|
726 |
|
727 | (function(module, exports) {
|
728 |
|
729 | module.exports = require("stats-webpack-plugin");
|
730 |
|
731 | }),
|
732 |
|
733 | (function(module, exports) {
|
734 |
|
735 | module.exports = require("webpack-dev-server");
|
736 |
|
737 | })
|
738 | ]);
|
739 |
|
\ | No newline at end of file |