Skip to content
This repository was archived by the owner on Jul 27, 2024. It is now read-only.

Commit a4467bc

Browse files
committed
some changes regarding build
- bulma is now processed by bundler instead of being downloaded directly from CDN - the bookmarklet entry point is now built separately from the site, as a library
1 parent b14c636 commit a4467bc

File tree

9 files changed

+64
-50
lines changed

9 files changed

+64
-50
lines changed

Closure_Front_End/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<meta http-equiv="X-UA-Compatible" content="IE=edge">
77
<meta name="viewport" content="width=device-width,initial-scale=1.0">
88
<link rel="icon" href="/favicon.ico">
9-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma-rtl.min.css">
109

1110
<!-- icons -->
1211
<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>

Closure_Front_End/package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Closure_Front_End/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"author": "noa_barlia",
66
"scripts": {
77
"serve": "vite",
8-
"build": "vite build",
8+
"build": "npm run build:site && npm run build:bookmarklet",
9+
"build:site": "vite build --config vite.config.js",
10+
"build:bookmarklet": "vite build --config vite-bookmarklet.config.js",
911
"preview": "vite preview --port 8080",
1012
"test:unit": "jest tests/unit",
1113
"lint": "eslint src --ext .vue,.js",
@@ -14,6 +16,7 @@
1416
"dependencies": {
1517
"@auth0/auth0-spa-js": "^1.15.0",
1618
"axios": "^0.21.1",
19+
"bulma": "^0.9.3",
1720
"core-js": "^3.6.5",
1821
"vue": "^3.0.0",
1922
"vue-router": "^4.0.0-0"

Closure_Front_End/src/App.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,7 @@ export default {
8585
},
8686
},
8787
};
88-
</script>
88+
</script>
89+
<style>
90+
@import "bulma/css/bulma-rtl.css";
91+
</style>

Closure_Front_End/src/huji-import/Bookmarklet.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default {
3333
} else {
3434
// TODO: rename `AUTH0_REDIRECT_URI' to something more informative
3535
const siteURL = import.meta.env.VITE_AUTH0_REDIRECT_URI
36-
const scrapeScriptFullURL = new URL("course-scrape-prod.js", siteURL)
36+
const scrapeScriptFullURL = new URL("course-scrape-prod.es.js", siteURL)
3737
console.log(`Generating bookmarklet for production, scrape script: ${scrapeScriptFullURL}`)
3838
3939
const url = encodeURI(`javascript:(async function() {

Closure_Front_End/src/huji-import/EmbeddedScrapeStatus.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export default {
115115
</script>
116116

117117
<style scoped>
118-
@import "https://cdn.jsdelivr.net/npm/bulma@0.9.2/css/bulma-rtl.min.css";
118+
@import "bulma/css/bulma-rtl.css";
119119
#courseScrapeRoot {
120120
margin: 5vh 5vw 5vh 5vw;
121121
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { defineConfig } from 'vite'
2+
import path from 'path'
3+
4+
import commonConfig from './vite-common.config.js'
5+
6+
// https://vitejs.dev/config/
7+
export default defineConfig({
8+
...commonConfig,
9+
build: {
10+
emptyOutDir: false,
11+
lib: {
12+
entry: path.resolve(__dirname, 'src/huji-import/course-scrape-entry.js'),
13+
name: 'course-scrape-prod',
14+
fileName: 'course-scrape-prod'
15+
},
16+
}
17+
})
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import vue from '@vitejs/plugin-vue'
2+
import eslint from '@rollup/plugin-eslint'
3+
import path from 'path'
4+
5+
/** @type{import('vite').UserConfigExport} */
6+
const commonConfig = {
7+
plugins: [vue(), { ...eslint({
8+
include: '**/*.+(vue|js|jsx|ts|tsx)'
9+
}), enforce: 'pre', apply: 'build'}],
10+
resolve: {
11+
alias: {
12+
'@': path.resolve(__dirname, '/src')
13+
}
14+
},
15+
server: {
16+
port: 8080,
17+
strictPort: true,
18+
hmr: {
19+
protocol: "ws", host: "localhost", port:8080
20+
}
21+
},
22+
}
23+
24+
export default commonConfig

Closure_Front_End/vite.config.js

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,8 @@
11
import { defineConfig } from 'vite'
2-
import vue from '@vitejs/plugin-vue'
3-
import eslint from '@rollup/plugin-eslint';
4-
import path from 'path'
5-
6-
7-
/** This function is used to determine the file-name of the production assets entry-points.
8-
*
9-
* By default, every asset except `index.html` is concatenated with a hash, which is useful for caching.
10-
* However, for the scrape script, we would like to have a constant path which we can reference when
11-
* generating the bookmarklet URL at build-time.
12-
*
13-
* @type {(chunkInfo: import('rollup').PreRenderedChunk) => string }
14-
**/
15-
const entryFileNameNamingRule = (chunkInfo) => {
16-
if (chunkInfo.name === "course-scrape-prod") {
17-
return "course-scrape-prod.js"
18-
}
19-
return "[name].[hash].js"
20-
}
212

3+
import commonConfig from './vite-common.config.js'
224

235
// https://vitejs.dev/config/
246
export default defineConfig({
25-
plugins: [vue(), { ...eslint({
26-
include: '**/*.+(vue|js|jsx|ts|tsx)'
27-
}), enforce: 'pre', apply: 'build'}],
28-
resolve: {
29-
alias: {
30-
'@': path.resolve(__dirname, '/src')
31-
}
32-
},
33-
server: {
34-
port: 8080,
35-
strictPort: true,
36-
hmr: {
37-
protocol: "ws", host: "localhost", port:8080
38-
}
39-
},
40-
build: {
41-
rollupOptions: {
42-
input: {
43-
main: path.resolve(__dirname, 'index.html'),
44-
"course-scrape-prod": path.resolve(__dirname, 'src/huji-import/course-scrape-entry.js')
45-
},
46-
output: {
47-
entryFileNames: entryFileNameNamingRule
48-
}
49-
}
50-
}
7+
...commonConfig
518
})

0 commit comments

Comments
 (0)