zm
2021-03-26 7ee3f469b6dcae60e04a08a02a6d4a6d657cb264
commit | author | age
7ee3f4 1 'use strict';
Z 2
3 module.exports = {
4     apply(compiler) {
5         compiler.hooks.emit.tap('compilation', compilation => {
6             // 遍历所有资源文件
7             for (let filePathName in compilation.assets) {
8                 if (/common\/main\.ttss/i.test(filePathName)) {
9                     console.log('\n-  字节跳动追加box-sizing:border-box...');
10                     // 获取文件内容
11                     let content = `*{-webkit-box-sizing:border-box;box-sizing:border-box}` + compilation.assets[filePathName].source() || '';
12                     // 重写指定输出模块内容
13                     compilation.assets[filePathName] = {
14                         source() {
15                             return content;
16                         },
17                         size() {
18                             return content.length;
19                         }
20                     };
21                 }
22             }
23
24         });
25     },
26 };