npm install @tntd/dll```
npm install @tntd/dll@~4.0.0 --save
yarn add @tntd/dll@~4.0.0
webpack修改
`${dllPath}/vendor/${dllName}_manifest.json
const { dllPath, dllName } = require('@tntd/dll');
static: [
{
directory: dllPath,
publicPath: '/' + configDev.staticPath
}
],
plugins: [
new webpack.DllReferencePlugin({
context: __dirname,
manifest: `
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/index.html',
inject: 'body',
pathPrefix: staticPath,
dllName,
hunksSortMode: 'none'
}),
new CopyWebpackPlugin({
patterns: [
{
from: dllPath + '/vendor',
to: path.join(__dirname, '../dist', staticPath + '/vendor')
}
]
}),
],
html修改:增加dll中css和js的引入
``
src="/<%= htmlWebpackPlugin.options.pathPrefix %>/vendor/<%= htmlWebpackPlugin.options.dllName %>.js">
安装依赖
3、使用 npm run build 构建dll
4、对比下 manifest.json 文件,对比下修改范围(有新增和修改的模块需要升级个小版本: 4.0.0 -> 4.1.0)
5、使用 npm publish` 发包