diff --git a/dist/server/build.js b/dist/server/build.js old mode 100755 new mode 100644 diff --git a/dist/server/config/utils.js b/dist/server/config/utils.js index 71b079521c34..9bb8c8fabeaf 100644 --- a/dist/server/config/utils.js +++ b/dist/server/config/utils.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports.nodeModulesPaths = exports.excludePaths = exports.includePaths = exports.OccurenceOrderPlugin = undefined; +exports.nodePaths = exports.nodeModulesPaths = exports.excludePaths = exports.includePaths = exports.OccurenceOrderPlugin = undefined; var _keys = require('babel-runtime/core-js/object/keys'); @@ -35,6 +35,12 @@ var includePaths = exports.includePaths = [_path2.default.resolve('./')]; var excludePaths = exports.excludePaths = [_path2.default.resolve('./node_modules')]; +var nodeModulesPaths = exports.nodeModulesPaths = _path2.default.resolve('./node_modules'); + +var nodePaths = exports.nodePaths = (process.env.NODE_PATH || '').split(process.platform === 'win32' ? ';' : ':').filter(Boolean).map(function (p) { + return _path2.default.resolve('./', p); +}); + // Load environment variables starts with STORYBOOK_ to the client side. function loadEnv() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; @@ -52,6 +58,4 @@ function loadEnv() { }); return env; -} - -var nodeModulesPaths = exports.nodeModulesPaths = _path2.default.resolve('./node_modules'); \ No newline at end of file +} \ No newline at end of file diff --git a/dist/server/config/webpack.config.js b/dist/server/config/webpack.config.js index cd52884819af..bef88fa3b564 100644 --- a/dist/server/config/webpack.config.js +++ b/dist/server/config/webpack.config.js @@ -27,6 +27,9 @@ exports.default = function () { }] }, resolve: { + // Add support to NODE_PATH. With this we could avoid relative path imports. + // Based on this CRA feature: https://github.com/facebookincubator/create-react-app/issues/253 + fallback: _utils.nodePaths, alias: { // This is to add addon support for NPM2 '@kadira/storybook-addons': require.resolve('@kadira/storybook-addons') diff --git a/dist/server/config/webpack.config.prod.js b/dist/server/config/webpack.config.prod.js index b37bc70ed70f..e72e3d9457b8 100644 --- a/dist/server/config/webpack.config.prod.js +++ b/dist/server/config/webpack.config.prod.js @@ -44,6 +44,9 @@ exports.default = function () { }] }, resolve: { + // Add support to NODE_PATH. With this we could avoid relative path imports. + // Based on this CRA feature: https://github.com/facebookincubator/create-react-app/issues/253 + fallback: _utils.nodePaths, alias: { // This is to add addon support for NPM2 '@kadira/storybook-addons': require.resolve('@kadira/storybook-addons') @@ -68,10 +71,10 @@ var _webpack = require('webpack'); var _webpack2 = _interopRequireDefault(_webpack); -var _utils = require('./utils'); - var _babelProd = require('./babel.prod.js'); var _babelProd2 = _interopRequireDefault(_babelProd); +var _utils = require('./utils'); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file diff --git a/src/server/config/utils.js b/src/server/config/utils.js index 16c73a58c384..34e9505fce8c 100644 --- a/src/server/config/utils.js +++ b/src/server/config/utils.js @@ -15,6 +15,13 @@ export const excludePaths = [ path.resolve('./node_modules'), ]; +export const nodeModulesPaths = path.resolve('./node_modules'); + +export const nodePaths = (process.env.NODE_PATH || '') + .split(process.platform === 'win32' ? ';' : ':') + .filter(Boolean) + .map(p => path.resolve('./', p)); + // Load environment variables starts with STORYBOOK_ to the client side. export function loadEnv(options = {}) { const defaultNodeEnv = options.production ? 'production' : 'development'; @@ -30,5 +37,3 @@ export function loadEnv(options = {}) { return env; } - -export const nodeModulesPaths = path.resolve('./node_modules'); diff --git a/src/server/config/webpack.config.js b/src/server/config/webpack.config.js index 6367d0033036..9e61e13ed043 100644 --- a/src/server/config/webpack.config.js +++ b/src/server/config/webpack.config.js @@ -8,6 +8,7 @@ import { excludePaths, nodeModulesPaths, loadEnv, + nodePaths, } from './utils'; import babelLoaderConfig from './babel.js'; @@ -49,6 +50,9 @@ export default function () { ], }, resolve: { + // Add support to NODE_PATH. With this we could avoid relative path imports. + // Based on this CRA feature: https://github.com/facebookincubator/create-react-app/issues/253 + fallback: nodePaths, alias: { // This is to add addon support for NPM2 '@kadira/storybook-addons': require.resolve('@kadira/storybook-addons'), diff --git a/src/server/config/webpack.config.prod.js b/src/server/config/webpack.config.prod.js index 86d6a276d619..180c4d229f78 100644 --- a/src/server/config/webpack.config.prod.js +++ b/src/server/config/webpack.config.prod.js @@ -1,7 +1,13 @@ import path from 'path'; import webpack from 'webpack'; -import { OccurenceOrderPlugin, includePaths, excludePaths, loadEnv } from './utils'; import babelLoaderConfig from './babel.prod.js'; +import { + OccurenceOrderPlugin, + includePaths, + excludePaths, + loadEnv, + nodePaths, +} from './utils'; export default function () { const entries = { @@ -54,6 +60,9 @@ export default function () { ], }, resolve: { + // Add support to NODE_PATH. With this we could avoid relative path imports. + // Based on this CRA feature: https://github.com/facebookincubator/create-react-app/issues/253 + fallback: nodePaths, alias: { // This is to add addon support for NPM2 '@kadira/storybook-addons': require.resolve('@kadira/storybook-addons'),