fis-conf.js 3.0 KB

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