Skip to content

Commit

Permalink
Ensure asset directory exists (#194)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
thebuilder authored and arunoda committed May 12, 2016
1 parent f6034db commit 1d28610
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/server/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1d28610

Please sign in to comment.