Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

18487_2 - Fix github CD issue after vite upgrade #194

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
</noscript>
<div id="app"></div>
<!-- built files will be auto injected by Vite -->
<script type="module" src="/src/main.ts"></script>
<script type="module" src="src/main.ts"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ http {
location / {
root /app;
index index.html;
try_files $uri $uri/ /index.html;
try_files $uri $uri/ /index.html =404;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used if none of the above files are found, it was nginx error before(missing index.html)

gzip on;
gzip_vary on;
gzip_min_length 10240;
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function syncSession () {

// in Vite, it need to manually include Workbox in service worker.
function registerServiceWorker() {
if ('serviceWorker' in navigator && process.env.NODE_ENV === 'production') {
if ('serviceWorker' in navigator && import.meta.env.NODE_ENV === 'production') {
navigator.serviceWorker.register(`${import.meta.env.BASE_URL}service-worker.js`)
.then(registration => {
registration.onupdatefound = () => {
Expand Down
9 changes: 5 additions & 4 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const generateAboutText = (aboutText1, aboutText2) => {
}

export default defineConfig(({ mode }) => {
const isLibBuild = mode === 'lib'
return {
define: {
'import.meta.env.ABOUT_TEXT': generateAboutText(aboutText1, aboutText2)
Expand All @@ -30,12 +31,12 @@ export default defineConfig(({ mode }) => {

build: {
sourcemap: true,
lib: {
lib: isLibBuild ? {
entry: path.resolve(__dirname, 'src/lib-setup.js'),
name: 'lib',
formats: ['umd'],
fileName: (format) => `lib.${format}.min.js`
},
} : undefined,
terserOptions: {
format: {
semicolons: false
Expand All @@ -44,14 +45,14 @@ export default defineConfig(({ mode }) => {
rollupOptions: {
external: (request) => {
// If library, use externals, otherwise the Vue/ composition-api instance in Auth-web will have issues.
if (mode === 'lib' && (/^@vue\/composition-api$/.test(request) || /^vue$/.test(request))) {
if (isLibBuild && (/^@vue\/composition-api$/.test(request) || /^vue$/.test(request))) {
return true
}
return false
}
},
outDir: 'lib',
minify: mode !== 'lib' ? false : 'terser'
minify: isLibBuild ? 'terser' : false
},
plugins: [
vue({
Expand Down
Loading