Skip to content

Instantly share code, notes, and snippets.

@hefangshi
Created June 23, 2016 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hefangshi/4a49368a7f12b87dc8498a6ac5cb05c1 to your computer and use it in GitHub Desktop.
Save hefangshi/4a49368a7f12b87dc8498a6ac5cb05c1 to your computer and use it in GitHub Desktop.
fis-npm.js
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