fis-conf.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. var version = '/1.1.0/';
  2. var path = '/p/commonDialog';
  3. fis.set('project.files', ['*.html', 'map.json']);
  4. fis.set('project.exclude', ['tpl/**.tmpl', '_dest/**']);
  5. fis.match('/static/sea.js', {
  6. isMod: false
  7. });
  8. fis.hook('cmd', {
  9. baseUrl: './src/modules/',
  10. paths: {
  11. "jquery": "jquery/jquery.js",
  12. "$": "jquery/jquery.js"
  13. }
  14. });
  15. /*设置发布路径*/
  16. fis.match(/^\/src\/(.*)/i, {
  17. release: version + '/$1',
  18. });
  19. // 配置图片压缩
  20. fis.match('**.png', {
  21. optimizer: fis.plugin('png-compressor', {
  22. type: 'pngquant'
  23. })
  24. });
  25. /*Sprite背景图移到staticPub/images*/
  26. fis.match(/^\/sass\/(.*\.(png|jpg|gif|jpeg))$/i, {
  27. release: 'img/sprite/$1',
  28. url: 'img/sprite/$1'
  29. });
  30. fis.match(/^\/src\/sass\/((.*)\.(css|less|scss|sass))$/i, {
  31. rExt: '.css',
  32. useSprite: true,
  33. parser: fis.plugin('node-sass'),
  34. postprocessor: fis.plugin('autoprefixer', {
  35. browsers: ['> 1%', 'last 2 versions'],
  36. cascade: true
  37. }),
  38. release: version + '/css/$1',
  39. url: './css/$1'
  40. }).match('_*.scss', {
  41. release: false
  42. })
  43. /*对CSS中的图片进行合并,包括html中的内联样式*/
  44. fis.match('*.{css,html,tpl}', {
  45. useSprite: true,
  46. });
  47. fis.match('*.tmpl', {
  48. isJsLike: true,
  49. release: false,
  50. parser: fis.plugin('utc')
  51. })
  52. /*css压缩*/
  53. fis.match('*.css', {
  54. optimizer: fis.plugin('clean-css')
  55. });
  56. /*启用 fis-spriter-csssprites 插件*/
  57. fis.match('::package', {
  58. spriter: fis.plugin('csssprites', {
  59. margin: 20,
  60. htmlUseSprite: true,/*开启模板内联css处理*/
  61. styleReg: /(<style(?:(?=\s)[\s\S]*?["'\s\w\/\-]>|>))([\s\S]*?)(<\/style\s*>|$)/ig
  62. }),
  63. postpackager: fis.plugin('loader', {
  64. resourceType: 'cmd'
  65. })
  66. });
  67. /*图片文件域名配置*/
  68. fis.media('dev').match('*.{jpg,png,jpeg,gif,css,js}', {
  69. domain: '../../',
  70. });
  71. fis.media('prod').match('*.{jpg,png,jpeg,gif,css,scss,js,woff,ttf,svg,eot}', {
  72. domain: 'http://pub.dwstatic.com' + path,
  73. }).match('::package', {
  74. postpackager: fis.plugin('loader', {
  75. allInOne: {
  76. resourceType: 'cmd',
  77. js: function (file) {
  78. return version + 'js/' + file.filename + ".js";
  79. },
  80. css: function (file) {
  81. return version + 'css/' + file.filename + ".css";
  82. }
  83. }
  84. })
  85. }).match('*.js', {
  86. optimizer: fis.plugin('uglify-js', {
  87. mangle: {
  88. except: 'exports, module, require, define'
  89. }
  90. })
  91. }).match('*.{js,css,png,jpg,gif,swf}', {
  92. useHash: true
  93. }).match(/^\/src\/sass\/((.*)\.(css|less|scss|sass))$/i, {
  94. url: version + 'css/$1',
  95. optimizer: fis.plugin('clean-css'),
  96. useHash: true
  97. }).match('sass/(**.png)', {
  98. release: version + 'img/sprite/$1'
  99. });