Created
June 23, 2016 11:45
-
-
Save hefangshi/4a49368a7f12b87dc8498a6ac5cb05c1 to your computer and use it in GitHub Desktop.
fis-npm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fis.enableNPM = function(options) { | |
fis.match('/node_modules/**.js', { | |
isMod: true | |
}); | |
if (options.autoPack) { | |
fis.match('/node_modules/**.js', { | |
packTo: options.npmBundlePath || '/pkg/npm/bundle.js' | |
}); | |
fis.match('/node_modules/**.css', { | |
packTo: options.npmCssBundlePath || '/pkg/npm/bundle.css' | |
}); | |
fis.on('deploy:start', function(groups) { | |
groups.forEach(function(group) { | |
var modified = group.modified; | |
var total = group.modified; | |
var file; | |
var i = modified.length - 1; | |
while ((file = modified[i--])) { | |
if (file.subpath.indexOf('/node_modules') === 0) { | |
modified.splice(i + 1, 1); | |
} | |
} | |
i = total.length - 1; | |
while ((file = total[i--])) { | |
if (file.subpath.indexOf('/node_modules') === 0) { | |
total.splice(i + 1, 1); | |
} | |
} | |
}); | |
}); | |
} | |
fis.match(options.src || '**.{js,es,jsx,ts,tsx}', { | |
preprocessor: [ | |
fis.plugin('js-require-file'), | |
fis.plugin('js-require-css') | |
] | |
}); | |
fis.unhook('components'); | |
fis.hook('node_modules'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment