This commit is contained in:
JUDIT GRESKOVITS 2017-05-23 14:30:14 +01:00 committed by Sérgio Ramos
parent d429f820e9
commit 80a417d33f

View File

@ -1,13 +1,3 @@
// @remove-on-eject-begin
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
// @remove-on-eject-end
'use strict'; 'use strict';
const fs = require('fs'); const fs = require('fs');
@ -26,23 +16,14 @@ const MODULES = [
path.join(UI_ROOT, 'node_modules'), path.join(UI_ROOT, 'node_modules'),
'node_modules' 'node_modules'
]; ];
const FRONTEND = path.join(FRONTEND_ROOT, 'src'); // duplicate const FRONTEND = path.join(FRONTEND_ROOT, 'src');
const UI = process.env.NODE_ENV === 'production' const UI = process.env.NODE_ENV === 'production'
? path.join(FRONTEND_ROOT, 'node_modules', '@tomgco/joyent-portal-ui', 'dist') ? path.join(FRONTEND_ROOT, 'node_modules', '@tomgco/joyent-portal-ui', 'dist')
: path.join(UI_ROOT, 'src'); // also duplicate : path.join(UI_ROOT, 'src');
const STATIC = path.join(FRONTEND_ROOT, 'static'); const STATIC = path.join(FRONTEND_ROOT, 'static');
const ESLINT = path.join(__dirname, '.eslintrc'); const ESLINT = path.join(__dirname, '.eslintrc');
// module.exports = originalConfig; const rules = originalConfig.module.rules.reduce((loaders, loader, index) => {
// module.exports = function() {
console.log('originalConfig = ', originalConfig);
// return originalConfig;
// config.module.rules[1].exclude.push(/\.(graphql|gql)$/);
const rules = originalConfig.module.rules.reduce((loaders, loader, index) => {
if(loader.test === /\.(js|jsx)$/) { if(loader.test === /\.(js|jsx)$/) {
loaders.push({ loaders.push({
test: loader.test, test: loader.test,
@ -72,15 +53,15 @@ const ESLINT = path.join(__dirname, '.eslintrc');
loaders.push(loader); loaders.push(loader);
} }
return loaders; return loaders;
}, []); }, []);
rules.push({ rules.push({
test: /\.(graphql|gql)$/, test: /\.(graphql|gql)$/,
exclude: /node_modules/, exclude: /node_modules/,
loader: require.resolve('graphql-tag/loader') loader: require.resolve('graphql-tag/loader')
}); });
const aliases = Object.assign({}, originalConfig.resolve.alias, fs.readdirSync(FRONTEND) const aliases = Object.assign({}, originalConfig.resolve.alias, fs.readdirSync(FRONTEND)
.map((name) => path.join(FRONTEND, name)) .map((name) => path.join(FRONTEND, name))
.filter((fullpath) => fs.statSync(fullpath).isDirectory()) .filter((fullpath) => fs.statSync(fullpath).isDirectory())
.reduce((aliases, fullpath) => Object.assign(aliases, { .reduce((aliases, fullpath) => Object.assign(aliases, {
@ -90,22 +71,11 @@ const ESLINT = path.join(__dirname, '.eslintrc');
'@ui': UI '@ui': UI
})); }));
const resolveModules = originalConfig.resolve.modules.concat(MODULES); const resolveModules = originalConfig.resolve.modules.concat(MODULES);
originalConfig.module.rules = rules; originalConfig.module.rules = rules;
originalConfig.resolve.alias = aliases; originalConfig.resolve.alias = aliases;
originalConfig.resolve.modules = resolveModules; originalConfig.resolve.modules = resolveModules;
originalConfig.resolve.plugins = []; originalConfig.resolve.plugins = [];
module.exports = originalConfig; module.exports = originalConfig;
// return originalConfig;
// resolves
// config.resolveLoader.modules = MODULES;
// config.resolve.modules = MODULES;
// set rules and return
// }