We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Webpack优化
4.dllPlugin 动态链接库 output:{ library:’ab’, libraryTarget:’commonjs’/’umd’/’var’ }
output:{ output:{ filename:’dll[name].js’, path:path.reslove(__dirname,’dist’), library:’dll[name]’ } }, plugins:[ new webpack.DllPlugin({ //name = library name:’dll[name]’, path:path.resolve(__dirname,’dist’,’manifest.json’) }) ]
Html :<script src=’/_dll_react.js’></script> plugins:[ new webpack.DllReferencePlugin({ manifest:path.resolve(__dirname,’dist’,’manifest.json’) }) ]
} plugins:[ new Happypack({ id:’js’, use:[{ loader:’babel-loader’, options:{ presets:[ ‘@babel/preset-env’, ‘@babel/preset-react’ ] } }] }), new Happypack({ id:’css’, use:[‘style-loader’,’css-loader’] }) ]
Webpack自带优化 1.//import 在生产环境下 会自动去掉没有用的代码 tree-shaking //require语法不支持tree-shaking 所以要用import 2.//scope hosting 作用域提升
Webpack插件 Compiler对象 每个webpack只有一个 Compilation 每次编译会产生,代表当前编译时的对象,编译一次就会产生一次 (包含entries,modules,chunks,assets,template(mainTemplate,chunkTemplate,hotupdateTemplate,runtimeTemplate,moduleTemplate))
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Webpack优化
不去解析类型jQuery这样的包。例:noParse:/jquery/
exclude:/node_modules/
4.dllPlugin 动态链接库
output:{
library:’ab’,
libraryTarget:’commonjs’/’umd’/’var’
}
output:{
output:{
filename:’dll[name].js’,
path:path.reslove(__dirname,’dist’),
library:’dll[name]’
}
},
plugins:[
new webpack.DllPlugin({ //name = library
name:’dll[name]’,
path:path.resolve(__dirname,’dist’,’manifest.json’)
})
]
Html :<script src=’/_dll_react.js’></script>
plugins:[
new webpack.DllReferencePlugin({
manifest:path.resolve(__dirname,’dist’,’manifest.json’)
})
]
module:{
rules:[{
test:/.js$/,
exclude:/node_modules/,
include:path.resolve(‘src’),
use:’happypack/loader?id=js’
},{
test:/.css$/,
use:’Happypack/loader?id=css’
}
]
}
plugins:[
new Happypack({
id:’js’,
use:[{
loader:’babel-loader’,
options:{
presets:[
‘@babel/preset-env’,
‘@babel/preset-react’
]
}
}]
}),
new Happypack({
id:’css’,
use:[‘style-loader’,’css-loader’]
})
]
Webpack自带优化
1.//import 在生产环境下 会自动去掉没有用的代码 tree-shaking
//require语法不支持tree-shaking 所以要用import
2.//scope hosting 作用域提升
Webpack插件
Compiler对象 每个webpack只有一个
Compilation 每次编译会产生,代表当前编译时的对象,编译一次就会产生一次
(包含entries,modules,chunks,assets,template(mainTemplate,chunkTemplate,hotupdateTemplate,runtimeTemplate,moduleTemplate))
The text was updated successfully, but these errors were encountered: