Skip to content

Commit

Permalink
fix: redundant copy of files for demo build
Browse files Browse the repository at this point in the history
  • Loading branch information
Vandish Gandhi committed Jul 17, 2019
1 parent 1295e71 commit d099c36
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ module.exports = {
appDemo: resolveApp('www'),
appSrc: resolveApp('src'),
appNodeModules: resolveApp('node_modules'),
assetsPath: resolveApp('www/assets'),
cnamePath: resolveApp('www/CNAME'),
};
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="shortcut icon" href="assets/favicon.ico">
<title>Adslot UI</title>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,700" rel="stylesheet">
</head>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"codecov": "cat coverage/coverage-final.json | codecov",
"dist:dev": "node ./scripts/build.js",
"dist:prod": "cross-env NODE_ENV=dist node ./scripts/build.js",
"dist:demo": "cross-env NODE_ENV=production node ./scripts/build.js",
"dist:demo": "cross-env NODE_ENV=production DEMO_ASSETS=true node ./scripts/build.js",
"dist": "npm run clean && npm run dist:prod && npm run dist:dev && npm run dist:demo",
"lint:sass": "sass-lint -v",
"lint:eslint": "eslint --ext .jsx,.js ./src && eslint --ext .jsx,.js ./www",
Expand Down
12 changes: 11 additions & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ function copyPublicFolder() {
});
}

function copyDemoAssets() {
fs.copySync(paths.assetsPath, `${buildPath}/assets`, {
dereference: true,
filter: file => file !== paths.appHtml,
});
fs.copyFileSync(paths.cnamePath, `${buildPath}/CNAME`);
}

// Create the production build and print the deployment instructions.
function build(previousFileSizes) {
console.log('Creating an optimized build...');
Expand Down Expand Up @@ -89,7 +97,9 @@ measureFileSizesBeforeBuild(buildPath)
// if you're in it, you don't end up in Trash
if (process.env.NODE_ENV === 'dist') fs.emptyDirSync(buildPath);
// Merge with the public folder
if (process.env.NODE_ENV === 'production') copyPublicFolder();
if (process.env.NODE_ENV === 'production') {
process.env.DEMO_ASSETS ? copyDemoAssets() : copyPublicFolder();
}
// Start the webpack build
return build(previousFileSizes);
})
Expand Down
Binary file added www/assets/favicon.ico
Binary file not shown.

0 comments on commit d099c36

Please sign in to comment.