1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _path = require('path');
|
8 |
|
9 | var _path2 = _interopRequireDefault(_path);
|
10 |
|
11 | var _assetsWebpackPlugin = require('assets-webpack-plugin');
|
12 |
|
13 | var _assetsWebpackPlugin2 = _interopRequireDefault(_assetsWebpackPlugin);
|
14 |
|
15 | var _webpack = require('webpack');
|
16 |
|
17 | var _babelRunner = require('babel-runner');
|
18 |
|
19 | var _projectSettings = require('./projectSettings');
|
20 |
|
21 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
22 |
|
23 | exports.default = function () {
|
24 | var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { creatingBuild: true },
|
25 | getWebpackAssets = _ref.getWebpackAssets,
|
26 | creatingBuild = _ref.creatingBuild,
|
27 | userSettings = _ref.userSettings;
|
28 |
|
29 | var namingConvention = creatingBuild ? '[name].[chunkhash]' : '[name]';
|
30 | var customizationOptions = {
|
31 | projectRoot: _projectSettings.projectRoot,
|
32 | creatingBuild: creatingBuild,
|
33 | namingConvention: namingConvention,
|
34 | assetsPath: _projectSettings.assetsPath,
|
35 | publicPath: _projectSettings.publicPath,
|
36 | babelrc: _babelRunner.babelrc
|
37 | };
|
38 |
|
39 |
|
40 | return userSettings.webpack.customize({
|
41 | entry: {
|
42 | app: [_projectSettings.entryPoint]
|
43 | },
|
44 | output: {
|
45 | path: _projectSettings.assetsPath,
|
46 | filename: namingConvention + '.js',
|
47 | chunkFilename: namingConvention + '.js',
|
48 | publicPath: _projectSettings.publicPath
|
49 | },
|
50 | module: {
|
51 | loaders: [{
|
52 | test: /\.jsx?$/,
|
53 | loaders: ['babel-loader?' + JSON.stringify(_babelRunner.babelrc)],
|
54 | exclude: /(node_modules)|\.route.jsx?$|\.dynamic.jsx?$/
|
55 | }, {
|
56 | test: /\.route.jsx?$|\.dynamic.jsx?$/,
|
57 | loaders: [
|
58 |
|
59 | 'bundle-loader?lazy&name=[name]', 'babel-loader?' + JSON.stringify(_babelRunner.babelrc)],
|
60 | exclude: /(node_modules)/
|
61 | }].concat(
|
62 |
|
63 | userSettings.webpack.loaders(customizationOptions))
|
64 | },
|
65 | plugins: [new _webpack.DefinePlugin({
|
66 | devToolkitSettings: JSON.stringify(userSettings.devToolkit),
|
67 |
|
68 | 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
|
69 | })].concat(getWebpackAssets ? [new _assetsWebpackPlugin2.default({
|
70 | path: _projectSettings.assetsManifestFolder,
|
71 | filename: _projectSettings.assetsManifestName,
|
72 | processOutput: getWebpackAssets
|
73 | })] : []).concat(creatingBuild ? [new _webpack.optimize.UglifyJsPlugin()] : [new _webpack.HotModuleReplacementPlugin(), new _webpack.NoEmitOnErrorsPlugin()]).concat(
|
74 |
|
75 | userSettings.webpack.plugins(customizationOptions)),
|
76 | resolve: {
|
77 | modules: [
|
78 |
|
79 | _path2.default.resolve(_projectSettings.devToolkitRoot, 'node_modules'),
|
80 |
|
81 | _path2.default.resolve(_projectSettings.projectRoot, 'node_modules'), 'node_modules']
|
82 | },
|
83 | resolveLoader: {
|
84 | modules: [
|
85 |
|
86 | _path2.default.resolve(_projectSettings.devToolkitRoot, 'node_modules'),
|
87 |
|
88 | _path2.default.resolve(_projectSettings.projectRoot, 'node_modules'), 'node_modules']
|
89 | }
|
90 | }, customizationOptions);
|
91 | }; |
\ | No newline at end of file |