config.wxgame.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /// 阅读 api.d.ts 查看文档
  2. ///<reference path="api.d.ts"/>
  3. import * as path from 'path';
  4. import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in';
  5. import { WxgamePlugin } from './wxgame/wxgame';
  6. import { CustomPlugin } from './myplugin';
  7. import * as defaultConfig from './config';
  8. const config: ResourceManagerConfig = {
  9. buildConfig: (params) => {
  10. const { target, command, projectName, version } = params;
  11. const outputDir = `../${projectName}_wxgame`;
  12. if (command == 'build') {
  13. return {
  14. outputDir,
  15. commands: [
  16. new CleanPlugin({ matchers: ["js", "resource"] }),
  17. new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }),
  18. new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
  19. new WxgamePlugin(),
  20. new ManifestPlugin({ output: 'manifest.js' })
  21. ]
  22. }
  23. }
  24. else if (command == 'publish') {
  25. return {
  26. outputDir,
  27. commands: [
  28. new CleanPlugin({ matchers: ["js", "resource"] }),
  29. new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
  30. new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
  31. new WxgamePlugin(),
  32. new UglifyPlugin([{
  33. sources: ["main.js"],
  34. target: "main.min.js"
  35. }
  36. ]),
  37. new ManifestPlugin({ output: 'manifest.js' })
  38. ]
  39. }
  40. }
  41. else {
  42. throw `unknown command : ${params.command}`;
  43. }
  44. },
  45. mergeSelector: defaultConfig.mergeSelector,
  46. typeSelector: defaultConfig.typeSelector
  47. }
  48. export = config;