Last active
February 15, 2019 09:34
-
-
Save abennouna/9196784cc5f6b584fda4cf5939074091 to your computer and use it in GitHub Desktop.
Extract Ionicons used in Ionic4 app (use at your own risk)
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
'use strict'; | |
const fs = require('fs'); | |
const template = require(process.cwd() + '/bin/angular-template.json'); | |
template.projects.app.architect.build.options.assets.push({ | |
glob: '**/*.svg', | |
input: 'node_modules/ionicons/dist/ionicons/svg', | |
output: './svg', | |
}); | |
fs.writeFileSync( | |
process.cwd() + '/angular.json', | |
JSON.stringify(template, null, 2), | |
); |
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
'use strict'; | |
const fs = require('fs'); | |
const template = require(process.cwd() + '/bin/angular-template.json'); | |
const foundIcons = fs | |
.readFileSync(process.cwd() + '/bin/found-icons.txt') | |
.toString() | |
.split('\n'); | |
foundIcons.filter(icon => icon).map(icon => { | |
template.projects.app.architect.build.options.assets.push({ | |
glob: icon, | |
input: 'node_modules/ionicons/dist/ionicons/svg', | |
output: './svg', | |
}); | |
}); | |
fs.writeFileSync( | |
process.cwd() + '/angular.json', | |
JSON.stringify(template, null, 2), | |
); |
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
{ | |
"$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json", | |
"version": 1, | |
"defaultProject": "app", | |
"newProjectRoot": "projects", | |
"projects": { | |
"app": { | |
"root": "", | |
"sourceRoot": "src", | |
"projectType": "application", | |
"prefix": "app", | |
"schematics": {}, | |
"architect": { | |
"build": { | |
"builder": "@angular-devkit/build-angular:browser", | |
"options": { | |
"outputPath": "www", | |
"index": "src/index.html", | |
"main": "src/main.ts", | |
"polyfills": "src/polyfills.ts", | |
"tsConfig": "src/tsconfig.app.json", | |
"assets": [{ | |
"glob": "**/*", | |
"input": "src/assets", | |
"output": "assets" | |
}, | |
"src/manifest.json", | |
"src/robots.txt", | |
"src/browserconfig.xml", | |
"src/favicon.ico", | |
{ | |
"glob": "**/*-sw.js", | |
"input": "src/app/sw", | |
"output": "/" | |
} | |
], | |
"styles": [{ | |
"input": "src/theme/variables.scss" | |
}, | |
{ | |
"input": "src/global.scss" | |
} | |
], | |
"scripts": [] | |
}, | |
"configurations": { | |
"production": { | |
"fileReplacements": [{ | |
"replace": "src/environments/environment.ts", | |
"with": "src/environments/environment.prod.ts" | |
}], | |
"optimization": true, | |
"outputHashing": "all", | |
"sourceMap": false, | |
"extractCss": true, | |
"namedChunks": false, | |
"aot": true, | |
"extractLicenses": true, | |
"vendorChunk": false, | |
"buildOptimizer": true, | |
"serviceWorker": true, | |
"budgets": [{ | |
"type": "initial", | |
"maximumWarning": "2mb", | |
"maximumError": "5mb" | |
}] | |
}, | |
"ci": { | |
"progress": false | |
} | |
} | |
}, | |
"serve": { | |
"builder": "@angular-devkit/build-angular:dev-server", | |
"options": { | |
"browserTarget": "app:build" | |
}, | |
"configurations": { | |
"production": { | |
"browserTarget": "app:build:production" | |
}, | |
"ci": { | |
"progress": false | |
} | |
} | |
}, | |
"extract-i18n": { | |
"builder": "@angular-devkit/build-angular:extract-i18n", | |
"options": { | |
"browserTarget": "app:build" | |
} | |
}, | |
"test": { | |
"builder": "@angular-devkit/build-angular:karma", | |
"options": { | |
"main": "src/test.ts", | |
"polyfills": "src/polyfills.ts", | |
"tsConfig": "src/tsconfig.spec.json", | |
"karmaConfig": "src/karma.conf.js", | |
"styles": [], | |
"scripts": [], | |
"assets": [{ | |
"glob": "favicon.ico", | |
"input": "src/", | |
"output": "/" | |
}, | |
{ | |
"glob": "**/*", | |
"input": "src/assets", | |
"output": "/assets" | |
}, | |
"src/manifest.json" | |
] | |
}, | |
"configurations": { | |
"ci": { | |
"progress": false, | |
"watch": false | |
} | |
} | |
}, | |
"lint": { | |
"builder": "@angular-devkit/build-angular:tslint", | |
"options": { | |
"tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"], | |
"exclude": ["**/node_modules/**"] | |
} | |
}, | |
"ionic-cordova-build": { | |
"builder": "@ionic/angular-toolkit:cordova-build", | |
"options": { | |
"browserTarget": "app:build" | |
}, | |
"configurations": { | |
"production": { | |
"browserTarget": "app:build:production" | |
} | |
} | |
}, | |
"ionic-cordova-serve": { | |
"builder": "@ionic/angular-toolkit:cordova-serve", | |
"options": { | |
"cordovaBuildTarget": "app:ionic-cordova-build", | |
"devServerTarget": "app:serve" | |
}, | |
"configurations": { | |
"production": { | |
"cordovaBuildTarget": "app:ionic-cordova-build:production", | |
"devServerTarget": "app:serve:production" | |
} | |
} | |
} | |
} | |
}, | |
"app-e2e": { | |
"root": "e2e/", | |
"projectType": "application", | |
"architect": { | |
"e2e": { | |
"builder": "@angular-devkit/build-angular:protractor", | |
"options": { | |
"protractorConfig": "e2e/protractor.conf.js", | |
"devServerTarget": "app:serve" | |
}, | |
"configurations": { | |
"ci": { | |
"devServerTarget": "app:serve:ci" | |
} | |
} | |
}, | |
"lint": { | |
"builder": "@angular-devkit/build-angular:tslint", | |
"options": { | |
"tsConfig": "e2e/tsconfig.e2e.json", | |
"exclude": ["**/node_modules/**"] | |
} | |
} | |
} | |
} | |
}, | |
"cli": { | |
"defaultCollection": "@ionic/angular-toolkit" | |
}, | |
"schematics": { | |
"@ionic/angular-toolkit:component": { | |
"styleext": "scss" | |
}, | |
"@ionic/angular-toolkit:page": { | |
"styleext": "scss" | |
} | |
} | |
} |
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
grep -R './src/app/' -o -e 'ion-icon name=".*"' \ | |
| awk '{print $2}' \ | |
| sort \ | |
| uniq \ | |
> ./bin/found-icons.txt \ | |
&& sed \ | |
-i '' \ | |
-e 's/^name="\(.*\)"$/\1.svg/g' \ | |
./bin/found-icons.txt \ | |
&& node ./bin/add-found-icons-to-build |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment