fis-conf.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. var version = '/1.4.8/';
  2. var path = '/p/dwplayer';
  3. fis.set('project.files', ['*.html', 'map.json']);
  4. fis.set('project.exclude', ['tpl/**.tmpl', '_dest/**']);
  5. fis.hook('commonjs', {
  6. baseUrl: './src/modules',
  7. extList: ['.js']
  8. });
  9. // 开启同名依赖
  10. fis.match('/src/modules/**', {
  11. useSameNameRequire: true,
  12. parser: fis.plugin('babel-5.x', {
  13. blacklist: ["useStrict"],
  14. loose: true,
  15. ignore: ["jQuery", "nicescroll"]
  16. })
  17. });
  18. // fis.match('/lib/**.js', {
  19. // release: version + '/$1',
  20. // packTo: 'lib.js'
  21. // });
  22. // 允许你在 js 中直接 require css+文件
  23. // fis.match('*.{js,es}', {
  24. // preprocessor: [
  25. // fis.plugin('js-require-file'),
  26. // fis.plugin('js-require-css', {
  27. // mode: 'dependency'
  28. // })
  29. // ]
  30. // });
  31. /*设置发布路径*/
  32. fis.match(/^\/src\/(.*)/i, {
  33. release: version + '/$1',
  34. // url: version + '/$1'
  35. });
  36. // 配置图片压缩
  37. fis.match('**.png', {
  38. optimizer: fis.plugin('png-compressor', {
  39. type: 'pngquant'
  40. })
  41. });
  42. /*Sprite背景图移到staticPub/images*/
  43. fis.match(/^\/sass\/(.*\.(png|jpg|gif|jpeg))$/i, {
  44. release: 'img/sprite/$1',
  45. url: 'img/sprite/$1'
  46. });
  47. fis.match(/^\/src\/sass\/((.*)\.(css|less|scss|sass))$/i, {
  48. rExt: '.css',
  49. useSprite: true,
  50. parser: fis.plugin('node-sass'),
  51. postprocessor: fis.plugin('autoprefixer', {
  52. browsers: ['> 1%', 'last 2 versions'],
  53. cascade: true
  54. }),
  55. release: version + '/css/$1',
  56. url: './css/$1'
  57. }).match('_*.scss', {
  58. release: false
  59. })
  60. /*对CSS中的图片进行合并,包括html中的内联样式*/
  61. fis.match('*.{css,html,tpl}', {
  62. useSprite: true,
  63. });
  64. fis.match('*.tmpl', {
  65. isJsLike: true,
  66. release: false,
  67. parser: fis.plugin('utc')
  68. })
  69. fis.match(/^\/src\/modules\/(.*\.js)$/i, {
  70. isMod: true
  71. });
  72. /*css压缩*/
  73. fis.match('*.css', {
  74. optimizer: fis.plugin('clean-css')
  75. });
  76. /*启用 fis-spriter-csssprites 插件*/
  77. fis.match('::package', {
  78. spriter: fis.plugin('csssprites',{
  79. margin: 20,
  80. htmlUseSprite: true,/*开启模板内联css处理*/
  81. styleReg: /(<style(?:(?=\s)[\s\S]*?["'\s\w\/\-]>|>))([\s\S]*?)(<\/style\s*>|$)/ig
  82. }),
  83. postpackager: fis.plugin('loader', {
  84. resourceType: 'commonJs',
  85. useInlineMap: true // 资源映射表内嵌
  86. })
  87. });
  88. /*图片文件域名配置*/
  89. fis.media('dev').match('*.{jpg,png,jpeg,gif,css,js}', {
  90. domain: '../../',
  91. });
  92. fis.media('prod').match('*.{jpg,png,jpeg,gif,css,scss,js,woff,ttf,svg,eot}', {
  93. domain: 'http://pub.dwstatic.com' + path,
  94. }).match('::package', {
  95. postpackager: fis.plugin('loader', {
  96. allInOne: {
  97. resourceType: 'mod',
  98. js: function (file) {
  99. return version + 'js/' + file.filename + ".js";
  100. },
  101. css: function (file) {
  102. return version + 'css/' + file.filename + ".css";
  103. }
  104. },
  105. resoucemap: version + 'js/${filepath}_map.js',
  106. })
  107. }).match('*.js', {
  108. optimizer: fis.plugin('uglify-js',{
  109. mangle: {
  110. except: 'exports, module, require, define'
  111. }
  112. })
  113. }).match('*.{js,css,png,jpg,gif,swf}', {
  114. useHash: true
  115. }).match(/^\/src\/modules\/(.*\.js)$/i, {
  116. useHash: false
  117. }).match(/^\/src\/sass\/((.*)\.(css|less|scss|sass))$/i, {
  118. url: version + 'css/$1',
  119. optimizer: fis.plugin('clean-css'),
  120. useHash: true
  121. }).match('sass/(**.png)', {
  122. release: version + 'img/sprite/$1'
  123. });