Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Commit

Permalink
๐Ÿ”จ Add build scripts for extension (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirusu400 authored Oct 31, 2021
1 parent d9a4a75 commit 4c12e45
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
4 changes: 3 additions & 1 deletion config/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ interface Paths {
appSrc: string;
appUserscript: string;
appMain: string;
appExtMain: string;
}

const paths: Paths = {
appDev: resolveApp('dev'),
appDist: resolveApp('dist'),
appSrc: resolveApp('src'),
appUserscript: resolveApp('src/klas-helper.user.js'),
appMain: resolveApp('src/main.js')
appMain: resolveApp('src/main.js'),
appExtMain: resolveApp('src/main-ext.js')
};

export default paths;
12 changes: 11 additions & 1 deletion config/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,14 @@ const mainConfig: webpack.Configuration = {
...commonConfig
};

export default [userscriptConfig, mainConfig];
const mainExtConfig: webpack.Configuration = {
name: 'main-ext',
entry: paths.appExtMain,
output: {
filename: 'main-ext.js',
path: paths.appDist
},
...commonConfig
};

export default [userscriptConfig, mainConfig, mainExtConfig];
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"dev:build": "cross-env NODE_ENV=development webpack --config config/webpack.config.ts --config-name userscript --progress",
"dev:start": "cross-env NODE_ENV=development webpack-dev-server --config config/webpack.config.ts --config-name main --host 0.0.0.0 --watch-poll",
"dev": "npm run dev:build && npm run dev:start",
"ext:build": "cross-env NODE_ENV=development webpack --config config/webpack.config.ts --config-name userscript --progress",
"ext:start": "cross-env NODE_ENV=development webpack-dev-server --config config/webpack.config.ts --config-name main-ext --host 0.0.0.0 --watch-poll",
"ext": "npm run ext:build && npm run ext:start",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"build": "cross-env NODE_ENV=production webpack --config config/webpack.config.ts --progress"
Expand Down
40 changes: 40 additions & 0 deletions src/main-ext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import routes from './routes';
import {
insertLibrary
} from './utils/dom';

// ํ™•์žฅ ํ”„๋กœ๊ทธ๋žจ์€ load๊ฐ€ ํ•„์š”์—†์Šต๋‹ˆ๋‹ค
(() => {
const dependencies = [
'https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.css',
'https://cdn.jsdelivr.net/npm/[email protected]/dist/Chart.min.js'
];

// ์˜์กด์„ฑ ์‚ฝ์ž…
for (const url of dependencies) {
insertLibrary(url);
}

// ๋ฉ”์ธ ํ•จ์ˆ˜ ์‹คํ–‰
if (Object.prototype.hasOwnProperty.call(routes, location.pathname)) {
routes[location.pathname]();
}

// KLAS Helper ์‚ฌ์šฉ ์—ฌ๋ถ€ ๋ฌธ๊ตฌ ์ถ”๊ฐ€
$('.navtxt').prepend(`
<span style="margin-right: 20px">
<a href="https://github.com/nbsp1221/klas-helper" target="_blank" rel="noopener">KLAS Helper</a> ์‚ฌ์šฉ ์ค‘
</span>
`);

// ์œ„๋กœ ๊ฐ€๊ธฐ ๋ฒ„ํŠผ ์œ„์น˜ ๊ณ ์ •
$('.btnup').css({
bottom: '30px',
position: 'fixed',
right: '30px'
});

// ๋กœ๊ทธ์ธ ์„ธ์…˜ ์œ ์ง€
setInterval(() => { fetch('/'); }, 600000);
})();

0 comments on commit 4c12e45

Please sign in to comment.