Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit36af369

Browse files
committed
create script for styles
1 parent6c73657 commit36af369

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

‎src/editor/ReactWebView.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,18 @@ class ReactWebView {
128128

129129
constmanifest=require(path.join(this.extensionPath,'build','asset-manifest.json'))
130130

131-
constmainStyle=manifest.files['main.css']
132-
conststylePathOnDisk=vscode.Uri.file(path.join(this.extensionPath,'build',mainStyle))
133-
conststyleUri=stylePathOnDisk.with({scheme:'vscode-resource'})
134-
135131
constgetSrc=(manifestName:string):any=>{
136132
constfile=manifest.files[manifestName]
137133
consturiPath=vscode.Uri.file(path.join(this.extensionPath,'build',file))
138134
returnuriPath.with({scheme:'vscode-resource'})
139135
}
140136

137+
conststyles=[
138+
'main.css',
139+
// get style chunk
140+
Object.keys(manifest.files).find(f=>f.match(/^static\/css\/.+\.css$/))||''
141+
].map(style=>getSrc(style))
142+
141143
// map over scripts
142144
constscripts=[{
143145
file:'./webpackBuild.js',
@@ -146,8 +148,8 @@ class ReactWebView {
146148
},{
147149
manifest:'main.js',
148150
},{
149-
//grab first file that matches chunk
150-
manifest:Object.keys(manifest.files).filter(f=>f.match(/^static\/js\/.+\.js$/))[0],
151+
//get js chunk
152+
manifest:Object.keys(manifest.files).find(f=>f.match(/^static\/js\/.+\.js$/)),
151153
}].map(script=>({
152154
nonce:getNonce(),
153155
src:script.manifest ?getSrc(script.manifest) :script.file
@@ -165,7 +167,7 @@ class ReactWebView {
165167
166168
<!-- TODO: load styles through package -->
167169
<!-- <link rel='stylesheet' href='https://unpkg.com/@alifd/next/dist/next.css' /> -->
168-
<!--<link rel='stylesheet' type='text/css' href='${styleUri}'> -->
170+
${styles.map(styleUri=>`<link rel='stylesheet' type='text/css' href='${styleUri}'>`).join('\n')}
169171
170172
<meta http-equiv='Content-Security-Policy' content="font-src *; img-src vscode-resource: https:; script-src${scripts.map(script=>`'nonce-${script.nonce}'`).join(' ')}; style-src vscode-resource: 'unsafe-inline' http: https: data:;">
171173
<base href='${buildUri}/'>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp