fis-conf.js 3.2 KB

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