@tntd/dll
v3.0.1
Published
同盾私有云通用dll文件
Maintainers
Keywords
Readme
安装
npm install @tntd/dll@^3.0.0 --save
yarn add @tntd/dll@^3.0.0使用
webpack修改
const { dllPath, dllName } = require('@tntd/dll');
<!-- 静态资源目录:dev -->
static: [
{
directory: dllPath,
publicPath: '/' + configDev.staticPath
}
],
plugins: [
<!-- 配置插件:dev\prod -->
new webpack.DllReferencePlugin({
context: __dirname,
manifest: `${dllPath}/vendor/${dllName}_manifest.json`
}),
<!-- 配置dll路径:dev\prod -->
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/index.html',
inject: 'body',
pathPrefix: staticPath,
dllName,
hunksSortMode: 'none'
}),
<!-- 拷贝dll到构建结果:prod -->
new CopyWebpackPlugin({
patterns: [
{
from: dllPath + '/vendor',
to: path.join(__dirname, '../dist', staticPath + '/vendor')
}
]
}),
],html修改:增加dll中css和js的引入
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/<%= htmlWebpackPlugin.options.pathPrefix %>/vendor/<%= htmlWebpackPlugin.options.dllName %>.css">
</head>
<body>
<div id="app"></div>
<script
src="/<%= htmlWebpackPlugin.options.pathPrefix %>/vendor/<%= htmlWebpackPlugin.options.dllName %>.js"></script>
</body>
</html>