fis-conf.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. var version = '';
  2. var path = '/zt2019/1907sdxl/';
  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. parser: fis.plugin('babel-5.x', {
  67. sourceMaps: true,
  68. blacklist: ['useStrict', 'regenerator'],
  69. loose: true,
  70. ignore: ['swiper']
  71. })
  72. });
  73. /*css压缩*/
  74. fis.match('*.css', {
  75. optimizer: fis.plugin('clean-css')
  76. });
  77. /*启用 fis-spriter-csssprites 插件*/
  78. fis.match('::package', {
  79. spriter: fis.plugin('csssprites',{
  80. margin: 20,
  81. htmlUseSprite: true,/*开启模板内联css处理*/
  82. styleReg: /(<style(?:(?=\s)[\s\S]*?["'\s\w\/\-]>|>))([\s\S]*?)(<\/style\s*>|$)/ig
  83. }),
  84. postpackager: fis.plugin('loader', {
  85. resourceType: 'commonJs',
  86. useInlineMap: true // 资源映射表内嵌
  87. })
  88. });
  89. /*图片文件域名配置*/
  90. fis.media('dev').match('*.{jpg,png,jpeg,gif,css,js}', {
  91. domain: '../../',
  92. });
  93. fis.media('prod').match('*.{jpg,png,jpeg,gif,css,scss,js,woff,ttf,svg,eot}', {
  94. domain: '//pub.dwstatic.com' + path,
  95. }).match('::package', {
  96. postpackager: fis.plugin('loader', {
  97. allInOne: {
  98. resourceType: 'mod',
  99. js: function (file) {
  100. return version + 'js/' + file.filename + ".js";
  101. },
  102. css: function (file) {
  103. return version + 'css/' + file.filename + ".css";
  104. }
  105. },
  106. resoucemap: version + 'js/${filepath}_map.js',
  107. })
  108. }).match('*.js', {
  109. optimizer: fis.plugin('uglify-js',{
  110. mangle: {
  111. except: 'exports, module, require, define'
  112. }
  113. })
  114. }).match(/^\/src\/sass\/((.*)\.(css|less|scss|sass))$/i, {
  115. url: version + 'css/$1',
  116. optimizer: fis.plugin('clean-css'),
  117. useHash: true
  118. }).match('sass/(**.png)', {
  119. release: version + 'img/sprite/$1'
  120. });