UNPKG

1.06 kBJavaScriptView Raw
1'use strict';
2
3var path = require('path');
4
5module.exports = function webpackExtra (config, appPath) {
6 var appPackage = require(path.join(appPath, 'package.json'));
7 var appHasOwnProperty = function (key) {
8 return Object.hasOwnProperty.bind(appPackage, key)();
9 }
10
11 if (appHasOwnProperty('extraBabelPlugins')) {
12 config.module.loaders = config.module.loaders.map(function (loader) {
13 if (loader.loader === 'babel') {
14 loader.query.plugins = (loader.query.plugins || [])
15 .concat(appPackage.extraBabelPlugins);
16 }
17
18 return loader;
19 })
20 }
21
22 config.module.loaders = config.module.loaders.map(function (loader) {
23 if (loader.loader === 'babel' && appHasOwnProperty('extraBabelPlugins')) {
24 loader.query.plugins = (loader.query.plugins || []).concat(appPackage.extraBabelPlugins);
25 }
26
27 if (loader.loader.indexOf('less') !== -1 && appHasOwnProperty('theme')) {
28 loader.loader += '?' + JSON.stringify({
29 modifyVars: appPackage.theme
30 });
31 };
32
33 return loader;
34 })
35
36 return config;
37}