Skip to content

Commit c6ac9c9

Browse files
committed
build process improvements
1 parent a751bee commit c6ac9c9

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

build/build.serviceWorker.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,38 @@ const manifest = () => {
9999
console.log("Manifest Done")
100100
}
101101

102+
const cleanIndex = () => {
103+
fs.readFile((dirPath + "/index.html"), "utf-8", function(err, data){
104+
data = data.replace(
105+
'<link rel="stylesheet" href="/assets/styles.css">',
106+
""
107+
);
108+
data = data.replace(
109+
'<link href="/assets/styles.css" rel="stylesheet">',
110+
""
111+
);
112+
data = data.replace(/type="text\/javascript"/gim, 'defer type="text/javascript"');
113+
data = data.replace(/rel="stylesheet"/gim, 'media="all" rel="stylesheet"');
114+
fs.writeFile((dirPath + "/index.html"), data, 'utf8');
115+
/* return new Promise((resolve, reject) => {
116+
self.assetFiles.forEach(file => {
117+
if (file.match(/styles\..*?\.css$/)) {
118+
_exec(`purifycss ${dirPath}${file} ${dirPath}/assets/js/app.js --min --info --out ${dirPath}${file}`);
119+
}
120+
resolve();
121+
})
122+
}) */
123+
});
124+
}
125+
102126
const exec = () => {
103127
generateAssetHash()
104128
.then(() => copyServiceWorker())
105129
.then(() => {
106130
serviceWorker();
107131
appCache();
108132
manifest();
133+
cleanIndex();
109134
})
110135
}
111136

0 commit comments

Comments
 (0)