1
mirror of https://github.com/pure-css/pure synced 2024-11-18 02:36:30 +01:00

refactor(site): pull pure files from npm install

This commit is contained in:
redonkulus 2022-03-14 15:44:15 -07:00
parent 2d9b809d4d
commit 72da9c0f20
5 changed files with 17 additions and 11 deletions

View File

@ -28,8 +28,6 @@ jobs:
npm ci
git config --global user.name "${GH_NAME}"
git config --global user.email "${GH_EMAIL}"
npm run prepare
cp -rf ./build/ ./site/static/css/pure/
cd site
npm install
npm run deploy

View File

@ -8,8 +8,7 @@
"scripts": {
"lint": "eslint . --ext .js",
"prepare": "grunt release",
"site:build": "npm run pretest && cd site && npm install && npm run build",
"site:start": "cd site && npm run start",
"start": "cd site && npm install && npm run start",
"test": "grunt test && tap test/*.js --no-coverage"
},
"files": [

View File

@ -2,10 +2,12 @@ const crypto = require('crypto');
const fs = require('fs');
const gzip = require('gzip-size');
const path = require('path');
const { version } = require('../../package.json');
const pureDir = path.resolve(__dirname, '..', 'static', 'css', 'pure');
const pureMin = fs.readFileSync(path.resolve(pureDir, 'pure-min.css'), 'utf8');
// load pure package metadata
const pureDir = path.dirname(require.resolve('purecss'));
const { version } = require(path.resolve(pureDir, 'package.json'));
const pureFiles = path.resolve(pureDir, 'build');
const pureMin = fs.readFileSync(path.resolve(pureFiles, 'pure-min.css'), 'utf8');
// use pure-min.css to determine site integrity hash
const sriHash = crypto.createHash('sha384').update(pureMin, 'utf8').digest('base64');
@ -15,7 +17,7 @@ module.exports.PURE_DOWNLOAD_SNIPPET = `<link rel="stylesheet" href="https://unp
// calculate each pure module size
module.exports.moduleSizes = function moduleSizes() {
const files = fs.readdirSync(pureDir);
const files = fs.readdirSync(pureFiles);
// collect all minified module files
const modules = files.filter(file => (/-min\.css$/).test(file))
@ -23,7 +25,7 @@ module.exports.moduleSizes = function moduleSizes() {
// get sizes across all modules
const moduleSizes = modules.map(module => {
const filePath = path.join(pureDir, module + '-min.css');
const filePath = path.join(pureFiles, module + '-min.css');
const contents = fs.readFileSync(filePath, { encoding: 'utf-8' });
return gzip.sync(contents);
});

View File

@ -8532,6 +8532,11 @@
"escape-goat": "^2.0.0"
}
},
"purecss": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/purecss/-/purecss-2.0.6.tgz",
"integrity": "sha512-R5V/Yk/j8/v5ivlg0MvQKQmo7F1BnWupK0wiMrKDyz2BofLB5BFKfZtSqu90YwHYBH4uzLtebmnDltY3ElcyLw=="
},
"qs": {
"version": "6.9.6",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.9.6.tgz",

View File

@ -5,8 +5,9 @@
"scripts": {
"build": "docusaurus build",
"deploy": "docusaurus deploy",
"predeploy": "npm run build",
"prestart": "cp -rf ../build/ ./static/css/pure/",
"predeploy": "npm run pure && npm run build",
"prestart": "npm run pure",
"pure": "cp -rf ./node_modules/purecss/build/ ./static/css/pure/",
"start": "docusaurus start",
"swizzle": "docusaurus swizzle"
},
@ -19,6 +20,7 @@
"common-tags": "^1.8.2",
"gzip-size": "^6.0.0",
"js-beautify": "^1.11.0",
"purecss": "^2.0.6",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-syntax-highlighter": "^15.5.0",