fis-conf.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. var version = '/1.0.0/';
  2. var path = '/zt2019/texuan';
  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(/^\/src\/sass\/((.*)\.(css|less|scss|sass))$/i, {
  47. rExt: '.css',
  48. useSprite: true,
  49. parser: fis.plugin('node-sass'),
  50. postprocessor: fis.plugin('autoprefixer', {
  51. browsers: ['> 1%', 'last 2 versions'],
  52. cascade: true
  53. }),
  54. release: version + '/css/$1',
  55. url: version + './css/$1'
  56. }).match('_*.scss', {
  57. release: false
  58. })
  59. /*对CSS中的图片进行合并,包括html中的内联样式*/
  60. fis.match('*.{css,html,tpl}', {
  61. useSprite: true,
  62. });
  63. fis.match('*.tmpl', {
  64. isJsLike: true,
  65. release: false,
  66. parser: fis.plugin('utc')
  67. })
  68. fis.match(/^\/src\/modules\/(.*\.js)$/i, {
  69. isMod: true
  70. });
  71. /*css压缩*/
  72. fis.match('*.css', {
  73. optimizer: fis.plugin('clean-css')
  74. });
  75. /*启用 fis-spriter-csssprites 插件*/
  76. fis.match('::package', {
  77. spriter: fis.plugin('csssprites',{
  78. margin: 20,
  79. htmlUseSprite: true,/*开启模板内联css处理*/
  80. styleReg: /(<style(?:(?=\s)[\s\S]*?["'\s\w\/\-]>|>))([\s\S]*?)(<\/style\s*>|$)/ig
  81. }),
  82. postpackager: fis.plugin('loader', {
  83. resourceType: 'commonJs',
  84. useInlineMap: true // 资源映射表内嵌
  85. })
  86. });
  87. /*图片文件域名配置*/
  88. fis.media('dev').match('*.{jpg,png,jpeg,gif,css,js}', {
  89. domain: '../../',
  90. });
  91. fis.media('prod').match('*.{jpg,png,jpeg,gif,css,scss,js,woff,ttf,svg,eot}', {
  92. domain: 'http://pub.dwstatic.com' + path,
  93. }).match('::package', {
  94. postpackager: fis.plugin('loader', {
  95. allInOne: {
  96. resourceType: 'mod',
  97. js: function (file) {
  98. return version + 'js/' + file.filename + ".js";
  99. },
  100. css: function (file) {
  101. return version + 'css/' + file.filename + ".css";
  102. }
  103. },
  104. resoucemap: version + 'js/${filepath}_map.js',
  105. })
  106. }).match('*.{js,css,png,jpg,gif,swf}', {
  107. useHash: false
  108. }).match(/^\/src\/modules\/(.*\.js)$/i, {
  109. useHash: false
  110. }).match(/^\/src\/sass\/((.*)\.(css|less|scss|sass))$/i, {
  111. url: version + 'css/$1',
  112. optimizer: fis.plugin('clean-css'),
  113. useHash: true
  114. }).match('sass/(**.png)', {
  115. release: version + 'img/sprite/$1'
  116. }).match('*.js', {
  117. optimizer: fis.plugin('uglify-js',{
  118. mangle: {
  119. except: 'exports, module, require, define'
  120. }
  121. })
  122. })