Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
komatsu-lease-app
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
komatsu
komatsu-lease-app
Commits
a85a639f
Commit
a85a639f
authored
Jun 07, 2023
by
胡
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: dist 目录统一删除esmodule内容脚本
parent
34e168c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
delDistModule.js
delDistModule.js
+33
-0
No files found.
delDistModule.js
0 → 100644
View file @
a85a639f
function
main
()
{
const
fs
=
require
(
'node:fs'
)
let
dirInfo
=
fs
.
readdirSync
(
'./dist'
)
if
(
!
dirInfo
.
length
)
return
console
.
log
(
'无dist文件夹'
)
for
(
let
index
=
0
;
index
<
dirInfo
.
length
;
index
++
)
{
let
indexHtmlPath
=
'./dist/'
+
dirInfo
[
index
]
+
'/index.html'
fs
.
readFile
(
indexHtmlPath
,
'utf8'
,
(
err
,
dataStr
)
=>
{
if
(
err
)
return
console
.
log
(
"读取文件失败!"
+
err
.
message
);
let
str
=
dataStr
.
toString
()
const
delContent
=
str
.
match
(
/<script.*
?
data-src="
[^
"
]
*".*
?
>
([\s\S]
*
?)
<
\/
script>/
)[
1
]
str
=
str
.
replace
(
/<script type="module"
(([\s\S])
*
?)
<
\/
script>/g
,
''
)
str
=
str
.
replace
(
/nomodule/g
,
''
)
.
replace
(
/crossorigin/g
,
''
)
.
replace
(
delContent
,
''
)
.
replace
(
/data-src/g
,
'src'
)
fs
.
writeFile
(
indexHtmlPath
,
str
,
function
(
err
)
{
if
(
err
)
return
err
;
console
.
log
(
indexHtmlPath
+
'页面替换成功'
)
});
})
}
}
main
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment