-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
29 lines (28 loc) · 1.04 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const fs = require('fs');
const path = require('path');
const directoryPath = path.join(__dirname, 'build');
const htmlFileToEdit = path.join(directoryPath, 'app', 'index.html');
fs.readFile(htmlFileToEdit, 'utf8', function (err, data) {
const res = data
.replace(/dist/g, 'app/dist')
.replace(/assets/g, 'app/assets')
.replace(/\/js/g, '/app/js')
.replace(/\/css/g, '/app/css');
fs.writeFile(htmlFileToEdit, res, 'utf8', function (err) {
if (err) return console.log(err);
});
});
const jsFilesToEditPath = path.join(directoryPath, 'app', 'dist');
fs.readdir(jsFilesToEditPath, (err, files) => {
const filesToEdits = files.filter((file) => file.endsWith('.js'));
filesToEdits.forEach((file) => {
fs.readFile(jsFilesToEditPath + '/' + file, 'utf8', function (err, data) {
const res = data
.replace(/dist/g, 'app/dist')
.replace(/assets/g, 'app/assets');
fs.writeFile(jsFilesToEditPath + '/' + file, res, 'utf8', function (err) {
if (err) return console.log(err);
});
});
});
});