DllPluginê³¼ DllReferencePluginì ë¹ë ìê° ì±ë¥ì í¬ê² í¥ììí¤ë ë°©ìì¼ë¡ ë²ë¤ì ë¶í íë ìë¨ì ì ê³µí©ëë¤. "DLL"ì´ë¼ë ì©ì´ë ìë Microsoftìì ëì
í ëì ë§í¬ ë¼ì´ë¸ë¬ë¦¬ë¥¼ ëíë
ëë¤.
ì´ íë¬ê·¸ì¸ì dll ì ì© ë²ë¤ì ìì±í기 ìí´ ë¨ë
ì¼ë¡ ë³ëì webpack ì¤ì ìì ì¬ì©ë©ëë¤. ìì¡´ì±ì 매íí기 ìí´ DllReferencePluginìì ì¬ì©íë manifest.jsoníì¼ì ìì±í©ëë¤.
context (ì í): 매ëíì¤í¸ íì¼ì ìì² ì»¨í
ì¤í¸ (기본ê°ì webpack 컨í
ì¤í¸)format (boolean = false): trueì¸ ê²½ì° ë§¤ëíì¤í¸ json íì¼(ì¶ë ¥)ì´ íìíë©ëë¤.name: ë
¸ì¶ë dll í¨ìì ì´ë¦ (TemplatePaths: [fullhash], [chunkhash], [contenthash], & [name] )path: 매ëíì¤í¸ json íì¼ì ì ë ê²½ë¡ (ì¶ë ¥)entryOnly (boolean = true): trueì¸ ê²½ì° ìí¸ë¦¬ í¬ì¸í¸ë§ ë
¸ì¶ë©ëë¤.type: dll ë²ë¤ì ì ínew webpack.DllPlugin(options);주ì´ì§ ê²½ë¡ì 기ë¡ëë manifest.jsonì ìì±í©ëë¤. ì¬ê¸°ìë requireì import ìì²ìì 모ë idë¡ì 매íì´ í¬í¨ë©ëë¤. ì´ë DllReferencePlugin ìì ì¬ì©ë©ëë¤.
ì´ íë¬ê·¸ì¸ì output.libraryìµì
ê³¼ ê²°í©íì¬ dll í¨ì를 ë
¸ì¶(ì ì ë²ìë¡ íë)í©ëë¤.
ì´ íë¬ê·¸ì¸ì 기본 webpack ì¤ì ìì ì¬ì©ëë©°, ì¬ì ë¹ëë ìì¡´ì±ì require í기 ìí´ dll ì ì© ë²ë¤ì 참조í©ëë¤.
context: 매ëíì¤í¸(ëë ì½í
ì¸ íë¡í¼í°)ì ìë ìì²ì (ì ë ê²½ë¡) 컨í
ì¤í¸extensions: dll ë²ë¤ì 모ëì í´ê²°íëë° ì¬ì©ëë íì¥ì
ëë¤(âì í¨ë²ìâ를 ì¬ì©í ëë§ ì¬ì©).manifest : content ë° nameì í¬í¨íë ê°ì²´ ëë ì»´íì¼ ì ë¡ëë JSON 매ëíì¤í¸ì ì ë ê²½ë¡ì ëí 문ìì´content (ì í): ìì²ìì 모ë id ë¡ì 매í(기본ê°ì manifest.content)name (ì í): dllì´ ë
¸ì¶ëë ìë³ì(기본ê°ì manifest.name)(externals 참조)scope (ì í): dllì ì½í
ì¸ ì ì ê·¼íëë° ì¬ì©ëë ì ëì¬sourceType (ì í): dllì´ ë
¸ì¶ëë ë°©ë²(libraryTarget)new webpack.DllReferencePlugin(options);dll 매ëíì¤í¸ íì¼ì 참조íì¬ ìì¡´ì± ì´ë¦ì 모ë idì 매íí ë¤ì, ë´ë¶ __webpack_require__í¨ì를 ì¬ì©íì¬ íìì ë°ë¼ ìì²í©ëë¤.
ì´ íë¬ê·¸ì¸ì scoped ì mapped ë ê°ì§ 모ëìì ì¬ì©í ì ììµëë¤.
dllì ì½í
ì¸ ë 모ë ì ëì¬ ìëìì ì ê·¼ ê°ë¥í©ëë¤. ì¦, scope = 'xyz'ë¡ dllì íì¼ abc ë require('xyz/abc')를 íµí´ ì ê·¼í ì ììµëë¤.
dllì ì½í ì¸ ë íì¬ ëë í°ë¦¬ì 매íë©ëë¤. íìí íì¼ì´ dllì íì¼ê³¼ íì¸ í ì¼ì¹íë ê²½ì°, dllì íì¼ì´ ëì ì¬ì©ë©ëë¤.
ì´ê²ì dll ë²ë¤ì 모ë íì¼ì í´ìí í ë°ìí기 ë문ì dll ë²ë¤ì ì¬ì©ìì ëí´ ëì¼í ê²½ë¡ë¥¼ ì¬ì©í ì ìì´ì¼ í©ëë¤. ì¦, dllì lodash ê° í¬í¨ëì´ ìê³ abc íì¼ì´ ìì¼ë©´ require('lodash') ë°require('./abc') ê° ë©ì¸ ë²ë¤ë¡ ë¹ëëì§ ìê³ dllìì ì¬ì©ë©ëë¤.
webpack.vendor.config.js
const path = require('path');
new webpack.DllPlugin({
context: __dirname,
name: '[name]_[fullhash]',
path: path.join(__dirname, 'manifest.json'),
});webpack.app.config.js
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./manifest.json'),
scope: 'xyz',
sourceType: 'commonjs2',
});ë ê°ì ê°ë³ ìì í´ëë¡, ì í¨ë²ìì 컨í ì¤í¸ë¥¼ ë³´ì¬ì¤ëë¤.