UNPKG

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