Skip to content

Commit

Permalink
Prevent infinite loop when exporting public path #415
Browse files Browse the repository at this point in the history
  • Loading branch information
ovidiuch committed Aug 25, 2017
1 parent 299fc74 commit c17f09b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/react-cosmos-webpack/src/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,16 @@ module.exports = function startExport() {
// Copy static files first, so that the built index.html overrides the its
// template file (in case the static assets are served from the root path)
if (publicPath) {
const exportPublicPath = path.join(outputPath, publicUrl);
fs.copySync(publicPath, exportPublicPath);
if (outputPath.indexOf(publicPath) === -1) {
const exportPublicPath = path.join(outputPath, publicUrl);
fs.copySync(publicPath, exportPublicPath);
} else {
console.warn(
`[Cosmos] Warning: Can't export public path because contains export path–avoiding infinite loop!`
);
console.warn('Public path:', publicPath);
console.warn('Export path:', outputPath);
}
}

runWebpackCompiler(loaderWebpackConfig)
Expand Down

0 comments on commit c17f09b

Please sign in to comment.