-
Notifications
You must be signed in to change notification settings - Fork 0
번들링시 노드모듈 예외처리
Yongku cho edited this page Mar 31, 2018
·
1 revision
번들링할 때 node_modules
의 외부모듈이 import
에 포함되어 있으면 번들링 트리에 포함이 된다.
하지만 해당 모듈이 ES6이상이면 Uglify할 때 Error가 발생한다.
그리고 번들링 파일이 커지므로 폐쇄망이 아니라면 node_modules
는 배포할 필요없다.
webpack에서는 webpack-node-externals라는 모듈을 사용하여 예외처리를 한다.
$ npm install webpack-node-externals --save-dev
var nodeExternals = require('webpack-node-externals');
...
module.exports = {
...
target: 'node', // in order to ignore built-in modules like path, fs, etc.
externals: [nodeExternals()], // in order to ignore all modules in node_modules folder
...
};