File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,30 @@ mpvueSimple.build()  // => Promise
3737``` 
3838
3939## changelog  
40+ #### ` 1.0.18 `  
41+ 
42+ -  加入可选配置项 ` externals ` ,通过在webpack中增加external属性的方式,可以在打包的时候移除公共模块的引入,从而减小包大小。
43+ 
44+   在构建脚本中进行如下定义:
45+ 
46+     ``` javascript 
47+   mpvueSimple .build ({
48+       externals:  {
49+           sdk:  ' require("../../../../sdk")' //  公共模块的相对路径
50+       },
51+   })
52+     ```
53+ 
54+   在页面文件中进行如下引用:
55+ 
56+     ` ` ` javascript
57+   import SDK from 'sdk'; // 注意这里的sdk,应为externals的key 
58+     ` ` `  
59+ 
60+ 
61+ 
4062
4163#### ` 1.0.17` 
64+ 
4265-  加入可选配置项 ` output.jsonpFunction` ` manifest.js` ` global.webpackJsonp` 
4366
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ module.exports = {
3939  resolveLoader : { 
4040    modules
4141  } , 
42+   externals : config . build . externals , 
4243  module : { 
4344    rules : [ 
4445      { 
Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ function mergeArgvConfig (config) {
101101    output : argvOutput ,                // pathString, undefined 
102102    config : argvCnf ,                   // pathString, undefined 
103103    definePlugin : argvDefinePlugin ,    // object, undefined 
104+     externals : argvExternals ,          // object, undefined 
104105    ...resetConfig 
105106  }  =  argv 
106107  const  mpType  =  argvComponent  ? 'component'  : 'page' 
@@ -142,6 +143,11 @@ function mergeArgvConfig (config) {
142143    const  assetsRoot  =  path . resolve ( outputPath ) 
143144    defConfig . assetsRoot  =  assetsRoot 
144145  } 
146+   
147+   // 外部扩展 
148+   if  ( argvExternals  &&  typeof  argvExternals  ===  'object' )  { 
149+     defConfig . externals  =  argvExternals 
150+   } 
145151
146152  const  allEntry  =  Object . keys ( defConfig . entry ) 
147153
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments