From 1d286102c172853006a42e61a36be7aa8f6c0d0b Mon Sep 17 00:00:00 2001 From: Daniel Schmidt Date: Thu, 12 May 2016 15:53:42 +0200 Subject: [PATCH] Ensure asset directory exists (#194) * Ensure asset directory exists Creating a static build would fail (Error: ENOENT: no such file or directory) if it encountered an asset in a subdirectory. Use mkdir to ensure the path exists, before writing the file. For example, referencing fonts would fail: ``` @font-face { font-family: 'vaud'; src: url('../fonts/vauddisplaybold-webfont.eot'); src: url('../fonts/vauddisplaybold-webfont.eot?#iefix') format('embedded-opentype'), url('../fonts/vauddisplaybold-webfont.woff') format('woff'), url('../fonts/vauddisplaybold-webfont.ttf') format('truetype'), url('../fonts/vauddisplaybold-webfont.svg#vaud_displayregular') format('svg'); font-weight: 700; font-style: normal; } ``` * Make ESlint happy --- src/server/build.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/server/build.js b/src/server/build.js index afd0d65e45f1..b1e74f7a3a97 100644 --- a/src/server/build.js +++ b/src/server/build.js @@ -66,6 +66,9 @@ webpack(config).compile(function (err, stats) { const source = asset._value; const dstPath = path.resolve(outputDir, `static/${filename}`); + + // Ensure the asset directory exists + shelljs.mkdir('-p', path.parse(dstPath).dir); fs.writeFileSync(dstPath, source); // We need to copy the manager bundle distributed via the React Storybook