fis-conf.js 3.4 KB

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