您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

96 行
3.1KB

  1. /// 阅读 api.d.ts 查看文档
  2. ///<reference path="api.d.ts"/>
  3. import * as path from 'path';
  4. import { UglifyPlugin, IncrementCompilePlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, RenamePlugin } from 'built-in';
  5. import { WxgamePlugin } from './wxgame/wxgame';
  6. import { BricksPlugin } from './bricks/bricks';
  7. import { CustomPlugin } from './myplugin';
  8. const config: ResourceManagerConfig = {
  9. buildConfig: (params) => {
  10. const { target, command, projectName, version } = params;
  11. if (command == 'build') {
  12. const outputDir = '.';
  13. return {
  14. outputDir,
  15. commands: [
  16. // new EmitResConfigFilePlugin({
  17. // output: "resource/default.res.json",
  18. // typeSelector: config.typeSelector,
  19. // nameSelector: p => path.basename(p).replace(/\./gi, "_"),
  20. // groupSelector: p => "preload"
  21. // }),
  22. new ExmlPlugin('debug'), // 非 EUI 项目关闭此设置
  23. new IncrementCompilePlugin(),
  24. ]
  25. }
  26. }
  27. else if (command == 'publish') {
  28. const outputDir = `bin-release/web/${version}`;
  29. return {
  30. outputDir,
  31. commands: [
  32. new CustomPlugin(),
  33. new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
  34. new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
  35. new UglifyPlugin([{
  36. sources: ["main.js"],
  37. target: "main.min.js"
  38. }]),
  39. new RenamePlugin({
  40. verbose: true, hash: 'crc32', matchers: [
  41. { from: "**/*.js", to: "[path][name]_[hash].[ext]" }
  42. ]
  43. }),
  44. new ManifestPlugin({ output: "manifest.json" })
  45. ]
  46. }
  47. }
  48. else {
  49. throw `unknown command : ${params.command}`
  50. }
  51. },
  52. mergeSelector: (path) => {
  53. if (path.indexOf("assets/bitmap/") >= 0) {
  54. return "assets/bitmap/sheet.sheet"
  55. }
  56. else if (path.indexOf("armature") >= 0 && path.indexOf(".json") >= 0) {
  57. return "assets/armature/1.zip";
  58. }
  59. },
  60. typeSelector: (path) => {
  61. const ext = path.substr(path.lastIndexOf(".") + 1);
  62. const typeMap = {
  63. "jpg": "image",
  64. "png": "image",
  65. "webp": "image",
  66. "json": "json",
  67. "fnt": "font",
  68. "pvr": "pvr",
  69. "mp3": "sound",
  70. "zip": "zip",
  71. "sheet": "sheet",
  72. "exml": "text"
  73. }
  74. let type = typeMap[ext];
  75. if (type == "json") {
  76. if (path.indexOf("sheet") >= 0) {
  77. type = "sheet";
  78. } else if (path.indexOf("movieclip") >= 0) {
  79. type = "movieclip";
  80. };
  81. }
  82. return type;
  83. }
  84. }
  85. export = config;