Skip to content
This repository has been archived by the owner on Jan 2, 2018. It is now read-only.

Commit

Permalink
Merge pull request #40 from rocjs/fix/changed-resolving-of-non-dev
Browse files Browse the repository at this point in the history
Changed how the default entry files are found
  • Loading branch information
dlmr authored Oct 23, 2016
2 parents 2ac5850 + 391bdbb commit 197ea5e
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions extensions/roc-package-web-app-react-dev/src/roc/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import path from 'path';

import { lazyFunctionRequire, generateDependencies } from 'roc';

import config from '../config/roc.config.js';
Expand Down Expand Up @@ -26,29 +28,33 @@ export default {
}, {
extension: 'roc',
hook: 'update-settings',
action: () => (readSettings) => () => {
action: ({ context: { usedExtensions } }) => (readSettings) => () => {
const settings = readSettings();
const newSettings = { build: { input: {} } };

if (!settings.build.input.web) {
newSettings.build.input.web = require.resolve('roc-package-web-app-react/app/default/client');
}
const rocPackageWebAppReact = usedExtensions.find(({ name }) => name === 'roc-package-web-app-react');

if (!settings.build.input.node) {
newSettings.build.input.node = require.resolve('roc-package-web-app-react/app/default/server');
}
if (rocPackageWebAppReact) {
if (!settings.build.input.web) {
newSettings.build.input.web = path.join(rocPackageWebAppReact.path, 'app/default/client.js');
}

if (!settings.build.input.node) {
newSettings.build.input.node = path.join(rocPackageWebAppReact.path, 'app/default/server.js');
}

if (settings.build.resources.length > 0) {
const resources = settings.build.resources.map((resource) => {
const matches = /^roc-package-web-app-react\/(.*)/.exec(resource);
if (matches && matches[1]) {
return require.resolve(`roc-package-web-app-react/${matches[1]}`);
}
if (settings.build.resources.length > 0) {
const resources = settings.build.resources.map((resource) => {
const matches = /^roc-package-web-app-react\/(.*)/.exec(resource);
if (matches && matches[1]) {
return path.join(rocPackageWebAppReact.path, `/${matches[1]}`);
}

return resource;
});
return resource;
});

newSettings.build.resources = resources;
newSettings.build.resources = resources;
}
}

// If a change has been done we will run the hook
Expand Down

0 comments on commit 197ea5e

Please sign in to comment.