fix: remove non-functional globalize/deglobalize scripts (#800)
fixes #787
This commit is contained in:
		
							parent
							
								
									0fa0658b59
								
							
						
					
					
						commit
						319a158deb
					
				
					 2 changed files with 1 additions and 48 deletions
				
			
		|  | @ -1,45 +0,0 @@ | |||
| #!/usr/bin/env node
 | ||||
| // Change all the Svelte CSS to just use globals everywhere,
 | ||||
| // to reduce CSS size and complexity.
 | ||||
| 
 | ||||
| const path = require('path') | ||||
| const fs = require('fs') | ||||
| const pify = require('pify') | ||||
| const writeFile = pify(fs.writeFile.bind(fs)) | ||||
| const readFile = pify(fs.readFile.bind(fs)) | ||||
| const glob = pify(require('glob')) | ||||
| const rimraf = pify(require('rimraf')) | ||||
| 
 | ||||
| const selectorRegex = /\n[ \t\n]*([0-9\w\- \t\n.:#,]+?)[ \t\n]*{/g | ||||
| const styleRegex = /<style>[\s\S]+?<\/style>/ | ||||
| 
 | ||||
| async function main () { | ||||
|   if (process.argv.includes('--reverse')) { // reverse the operation we just did
 | ||||
|     let tmpComponents = await glob('./routes/**/.tmp-*.html') | ||||
|     for (let filename of tmpComponents) { | ||||
|       let text = await readFile(filename, 'utf8') | ||||
|       await rimraf(filename) | ||||
|       let originalFilename = path.join(path.dirname(filename), path.basename(filename).substring(5)) | ||||
|       await writeFile(originalFilename, text, 'utf8') | ||||
|     } | ||||
|   } else { // read all files, copy to tmp files, rewrite files to include global CSS everywhere
 | ||||
|     let components = await glob('./routes/**/*.html') | ||||
|     for (let filename of components) { | ||||
|       let text = await readFile(filename, 'utf8') | ||||
|       let newText = text.replace(styleRegex, style => { | ||||
|         return style.replace(selectorRegex, selectorMatch => { | ||||
|           return selectorMatch.replace(/\S[^{]+/, selector => `:global(${selector})`) | ||||
|         }) | ||||
|       }) | ||||
|       let newFilename = path.join(path.dirname(filename), '.tmp-' + path.basename(filename)) | ||||
| 
 | ||||
|       await writeFile(newFilename, text, 'utf8') | ||||
|       await writeFile(filename, newText, 'utf8') | ||||
|     } | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| Promise.resolve().then(main).catch(err => { | ||||
|   console.error(err) | ||||
|   process.exit(1) | ||||
| }) | ||||
|  | @ -10,7 +10,7 @@ | |||
|     "sapper-dev": "cross-env PORT=4002 sapper dev", | ||||
|     "sapper-prod": "cross-env PORT=4002 node __sapper__/build", | ||||
|     "build": "cross-env NODE_ENV=production npm run build-steps", | ||||
|     "build-steps": "run-s globalize-css build-sass build-svg build-inline-script sapper-build deglobalize-css", | ||||
|     "build-steps": "run-s build-sass build-svg build-inline-script sapper-build", | ||||
|     "sapper-build": "sapper build", | ||||
|     "start": "cross-env NODE_ENV=production npm run sapper-prod", | ||||
|     "build-and-start": "run-s build start", | ||||
|  | @ -32,8 +32,6 @@ | |||
|     "test-unit": "mocha -r esm tests/unit/", | ||||
|     "wait-for-mastodon-to-start": "node -r esm bin/wait-for-mastodon-to-start.js", | ||||
|     "wait-for-mastodon-data": "node -r esm bin/wait-for-mastodon-data.js", | ||||
|     "globalize-css": "node ./bin/globalize-css.js", | ||||
|     "deglobalize-css": "node ./bin/globalize-css.js --reverse", | ||||
|     "deploy-prod": "DEPLOY_TYPE=prod ./bin/deploy.sh", | ||||
|     "deploy-dev": "DEPLOY_TYPE=dev ./bin/deploy.sh", | ||||
|     "deploy-all-travis": "./bin/deploy-all-travis.sh", | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue