-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Patterns deployment cache #1088
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { buildCSS, runTests, watchJS } from '@hypothesis/frontend-build'; | ||
import * as fs from 'fs'; | ||
import gulp from 'gulp'; | ||
|
||
import { servePatternLibrary } from './scripts/serve-pattern-library.js'; | ||
|
@@ -60,3 +61,29 @@ gulp.task( | |
}) | ||
) | ||
); | ||
|
||
gulp.task('update-patterns-index', async () => { | ||
// Determine the name of the JS/CSS bundles (in prod they could contain a hash) | ||
const jsBundleName = fs | ||
.readdirSync('build/scripts') | ||
.find(file => file.startsWith('pattern-library')); | ||
const cssBundleName = fs | ||
.readdirSync('build/styles') | ||
.find(file => file.startsWith('pattern-library')); | ||
|
||
if (!jsBundleName || !cssBundleName) { | ||
throw new Error( | ||
'JS and/or CSS bundles missing. Make sure bundles are generated first' | ||
); | ||
} | ||
|
||
// Replace references to the generic bundle names with the resolved ones | ||
const indexContent = fs | ||
.readFileSync('templates/index.html') | ||
.toString() | ||
.replace('pattern-library.bundle.js', jsBundleName) | ||
.replace('pattern-library.css', cssBundleName); | ||
|
||
// eslint-disable-next-line no-undef | ||
fs.writeFileSync('templates/index.html', Buffer.from(indexContent)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The dumbest possible template renderer is to use some obvious placeholder like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We recently renamed this file to change the mustache-specific extension to |
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot set
ENV NODE_ENV=production
for the whole docker stage, because thenyarn install
does not install dev dependencies, which are needed for bundling.