add-icon-assets.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. "use strict";
  2. /**
  3. * Use of this source code is governed by an MIT-style license that can be
  4. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  5. */
  6. Object.defineProperty(exports, "__esModule", { value: true });
  7. exports.addIconToAssets = addIconToAssets;
  8. const schematics_1 = require("@angular/cdk/schematics");
  9. const utility_1 = require("@schematics/angular/utility");
  10. const chalk_1 = require("chalk");
  11. const iconPathSegment = '@ant-design/icons-angular';
  12. const iconAssetObject = {
  13. 'glob': '**/*',
  14. 'input': './node_modules/@ant-design/icons-angular/src/inline-svg/',
  15. 'output': '/assets/'
  16. };
  17. function addIconToAssets(options) {
  18. return (0, utility_1.updateWorkspace)(workspace => {
  19. const project = (0, schematics_1.getProjectFromWorkspace)(workspace, options.project);
  20. const targetOptions = (0, schematics_1.getProjectTargetOptions)(project, 'build');
  21. if (!targetOptions.assets) {
  22. targetOptions.assets = [Object.assign({}, iconAssetObject)];
  23. }
  24. else {
  25. const assets = targetOptions.assets;
  26. const assetsString = JSON.stringify(assets);
  27. if (!assetsString.includes(iconPathSegment)) {
  28. assets.push(Object.assign({}, iconAssetObject));
  29. }
  30. else {
  31. console.log();
  32. console.log((0, chalk_1.yellow)(`Could not add the icon assets to the CLI project assets ` +
  33. `because there is already a icon assets file referenced.`));
  34. console.log((0, chalk_1.yellow)(`Please manually add the following config to your assets:`));
  35. console.log((0, chalk_1.cyan)(JSON.stringify(iconAssetObject, null, 2)));
  36. return;
  37. }
  38. }
  39. });
  40. }
  41. //# sourceMappingURL=add-icon-assets.js.map