This repository has been archived by the owner on Mar 14, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use bootstrap.js/app.css again (#3395)
* use bootstrap.js/app.css again * include hashed sw assets * add helper for fetching resource version * unneeded dep
- Loading branch information
Showing
11 changed files
with
152 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* @fileoverview Helper that reads and checks the resource path | ||
*/ | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
/** | ||
* Finds the resource path for the given name, and confirms that the file exists (throwing an | ||
* Error otherwise). Returns the path including any query parameters, but without any leading "/", | ||
* for use in caching. | ||
* | ||
* @param {string} name | ||
* @return {string} | ||
*/ | ||
function resourcePath(name) { | ||
name = name.toUpperCase(); | ||
|
||
const f = path.join( | ||
__dirname, | ||
'../../src/site/_data', | ||
`resource${name}.json`, | ||
); | ||
|
||
const raw = JSON.parse(fs.readFileSync(f), 'utf-8'); | ||
|
||
const {path: rawPath} = raw; | ||
if (rawPath === undefined) { | ||
throw new Error(`could not find 'path' key in: ${f}`); | ||
} | ||
|
||
const cleanPath = rawPath.split('?')[0]; // remove trailing query params | ||
const check = path.join(__dirname, '../../dist', cleanPath); | ||
if (!fs.existsSync(check)) { | ||
throw new Error(`path did not exist: ${check}`); | ||
} | ||
|
||
return rawPath[0] === '/' ? rawPath.substr(1) : rawPath; | ||
} | ||
|
||
module.exports = resourcePath; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
const isProd = process.env.ELEVENTY_ENV === 'prod'; | ||
const noop = (url) => url; | ||
const strip = (url) => url.split('?')[0]; | ||
|
||
// Strip query params from URLs in dev only. Used for lazy cache-busting | ||
// e.g. in non-prod, app.css?blah => app.css | ||
module.exports = isProd ? noop : strip; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.