Comments (12)
@YunYouJun vitejs/vite#1791 (comment)
from vite-ssg.
@YunYouJun use typeof window !== 'undefined'
instead, on SSR/SSG navigator
is not defined.
See #21 (comment)
from vite-ssg.
@YunYouJun use
typeof window !== 'undefined'
instead, on SSR/SSGnavigator
is not defined.See #21 (comment)
In fact, I tried to do it, but it didn't work either. (typeof window !== 'undefined'
)
from vite-ssg.
@YunYouJun I'll take a look at your repo...
from vite-ssg.
@YunYouJun I'll take a look at your repo...
Thanks, main file is https://github.com/YunYouJun/web-resume/blob/main/src/pages/editor.vue.
from vite-ssg.
@YunYouJun what are you using npm
, pnpm
or yarn
? There is no lock file on your repo...
from vite-ssg.
@YunYouJun what are you using
npm
,pnpm
oryarn
? There is no lock file on your repo...
Because lockfile is large and it is not a project that requires a fixed dependency, I ignored the lock file.
Yarn
or pnpm
is OK, I'm currently using pnpm
.
from vite-ssg.
@YunYouJun I have your repo build working:
Change serve script
with: "serve": "vite preview"
(remove the hyphen).
Change src/pages/editor.vue
just remove import * as monaco from 'monaco-editor'
and onMounted
configure this:
onMounted(async() => {
const txt = await useResume(route.query.url as string)
resumeTxt.value = txt
console.log(txt)
if (typeof window !== 'undefined' && container.value) {
const monaco = await import('monaco-editor')
monaco.editor.create(container.value, {
value: resumeTxt.value,
language: 'yaml',
theme: 'vs-dark',
wordWrap: 'on',
})
}
})
Since we are using monaco editor
we need to change rollup options on vite
config file: on SSG build the monaco dep will go to the temporary main.js (5MB)
(the entry point for vite-ssg
for build) and then will fail, since there is some usage to detect browser:
// vite.config.ts
...
...
import path from 'path'
const prefix = 'monaco-editor/esm/vs'
// import yaml from '@rollup/plugin-yaml'
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
...
...
build: {
rollupOptions: {
output: {
inlineDynamicImports: false,
manualChunks: {
jsonWorker: [`${prefix}/language/json/json.worker`],
cssWorker: [`${prefix}/language/css/css.worker`],
htmlWorker: [`${prefix}/language/html/html.worker`],
tsWorker: [`${prefix}/language/typescript/ts.worker`],
editorWorker: [`${prefix}/editor/editor.worker`],
},
},
},
},
// https://github.com/antfu/vite-ssg
ssgOptions: {
script: 'async',
formatting: 'minify',
from vite-ssg.
It works. Thank you very much!
from vite-ssg.
Is it possible for us to do this automatically with vite-ssg? For example, detects the 'worker .js' suffix name when packaging.
from vite-ssg.
@YunYouJun the problem is that we don't know if the worker is pre-bundled or not so the problem is on the user land, we cannot assume all workers requires pre-bundle them and of course how to do it ;).
from vite-ssg.
Okay, I see.
from vite-ssg.
Related Issues (20)
- lottie-web build ssg 报错Ω HOT 1
- Support stripe-away slot of `ClientOnly` on SSG
- add quasar 2.14.0 with vite 5.0.0 pnpm build failed
- Inferred type of createApp HOT 2
- let headers = new Headers() returning undefined in @servicestack node modules
- Cannot import CommonJS module
- Implement optional route parameters
- issue with build
- Cannot access the right router HOT 1
- Can'not build with vue-select HOT 1
- SSG for just home page? HOT 1
- build exception when add jsx support and change all vue to jsx.
- re-rendering issues
- fetch gives 'ERR_INVALID_URL' HOT 1
- using build.rollupOptions.output.manualChunks
- Adding ClientOnly to any part of the App.Vue gives an empty error HOT 1
- html-minifier high security vulnerability HOT 5
- SyntaxError: Cannot use import statement outside a module HOT 3
- How to remove crossorigin from html tags? HOT 1
- Vite-ssg build error in SSR step HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vite-ssg.