From 2890dd35f3462b4fec00f9d357318543ab8aa311 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 23 Aug 2017 00:03:13 +0200 Subject: [PATCH 1/2] FIX #1709 --- app/react/src/server/config/babel.js | 3 --- app/vue/src/server/config.js | 13 ++++++++++--- app/vue/src/server/config/babel.js | 1 - 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/react/src/server/config/babel.js b/app/react/src/server/config/babel.js index 0754c278511c..31c88ebfcf7a 100644 --- a/app/react/src/server/config/babel.js +++ b/app/react/src/server/config/babel.js @@ -1,9 +1,6 @@ -const findCacheDir = require('find-cache-dir'); - module.exports = { // Don't try to find .babelrc because we want to force this configuration. babelrc: false, - cacheDirectory: findCacheDir({ name: 'react-storybook' }), presets: [ [ require.resolve('babel-preset-env'), diff --git a/app/vue/src/server/config.js b/app/vue/src/server/config.js index 38971fdc4ed6..898e35574d42 100644 --- a/app/vue/src/server/config.js +++ b/app/vue/src/server/config.js @@ -1,6 +1,7 @@ /* eslint-disable global-require, import/no-dynamic-require */ import fs from 'fs'; import path from 'path'; +import findCacheDir from 'find-cache-dir'; import loadBabelConfig from './babel_config'; // avoid ESLint errors @@ -11,10 +12,16 @@ const logger = console; // (inside working directory) if a config path is not provided. export default function(configType, baseConfig, configDir) { const config = baseConfig; - + const babelConfig = loadBabelConfig(configDir); - config.module.rules[0].query = babelConfig; - + config.module.rules[0].query = { + // This is a feature of `babel-loader` for webpack (not Babel itself). + // It enables a cache directory for faster-rebuilds + // `find-cache-dir` will create the cache directory under the node_modules directory. + cacheDirectory: findCacheDir({ name: 'react-storybook' }), + ...babelConfig, + }; + // Check whether a config.js file exists inside the storybook // config directory and throw an error if it's not. const storybookConfigPath = path.resolve(configDir, 'config.js'); diff --git a/app/vue/src/server/config/babel.js b/app/vue/src/server/config/babel.js index 0754c278511c..0fd3d444b0a8 100644 --- a/app/vue/src/server/config/babel.js +++ b/app/vue/src/server/config/babel.js @@ -3,7 +3,6 @@ const findCacheDir = require('find-cache-dir'); module.exports = { // Don't try to find .babelrc because we want to force this configuration. babelrc: false, - cacheDirectory: findCacheDir({ name: 'react-storybook' }), presets: [ [ require.resolve('babel-preset-env'), From d0b51769e3f8f691a82465062b7b6f53483f4406 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 23 Aug 2017 07:50:16 +0200 Subject: [PATCH 2/2] Linting --- app/vue/src/server/config.js | 4 ++-- app/vue/src/server/config/babel.js | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/vue/src/server/config.js b/app/vue/src/server/config.js index 898e35574d42..07425bd19cba 100644 --- a/app/vue/src/server/config.js +++ b/app/vue/src/server/config.js @@ -12,7 +12,7 @@ const logger = console; // (inside working directory) if a config path is not provided. export default function(configType, baseConfig, configDir) { const config = baseConfig; - + const babelConfig = loadBabelConfig(configDir); config.module.rules[0].query = { // This is a feature of `babel-loader` for webpack (not Babel itself). @@ -21,7 +21,7 @@ export default function(configType, baseConfig, configDir) { cacheDirectory: findCacheDir({ name: 'react-storybook' }), ...babelConfig, }; - + // Check whether a config.js file exists inside the storybook // config directory and throw an error if it's not. const storybookConfigPath = path.resolve(configDir, 'config.js'); diff --git a/app/vue/src/server/config/babel.js b/app/vue/src/server/config/babel.js index 0fd3d444b0a8..31c88ebfcf7a 100644 --- a/app/vue/src/server/config/babel.js +++ b/app/vue/src/server/config/babel.js @@ -1,5 +1,3 @@ -const findCacheDir = require('find-cache-dir'); - module.exports = { // Don't try to find .babelrc because we want to force this configuration. babelrc: false,