BH] Svelte ํํ ๋ฆฌ์ผ - 1ํธ (Trello)
[BH] ์๋ ํ์ธ์.
Svelte๋ฅผ ์ฌ์ฉํ์ฌ Trello๋ฅผ ๋ง๋ค์ด๋ณผ ๊ฑฐ์์.
์ด๋ฒ์ Svelte ์ ํํ ์ด์ ๋!!!!!
์์ต๋๋ค. ๊ทธ๋ฅ ํด๋ณด๊ณ ์ถ์ด์ ํ๋๊ฑฐ์์
1.์ค์น
๋จผ์ Svelte๋ฅผ ์ค์นํฉ๋๋ค.
{์ํ๋ ๊ฒฝ๋ก} ์ ํ ex) c:\dev
> npx degit sveltejs/template svelte-app
> cd svelte-app
> npm i
> npm run dev
์ ์ http://localhost:5000/ ๊ธฐ๋ณธ ํฌํธ๋ 5000์ ๋๋ค.
SCSS ์ถ๊ฐ
npm i sass
npm i rollup-plugin-scss
์ค์น๊ฐ ์๋ฃ๋๋ฉด rollup.config.js ์ถ๊ฐํด์ค๋๋ค.
rollup.config.js
import scss from "rollup-plugin-scss";
export default {
...
plugins: [
...
scss({
sourceMap: true,
sass: require("sass"),
})
]
};
๋ง์ฝ vscode๋ก ์ฝ๋ ์์ฑ์ค์ด์ ๋ถ๋ค์ด๋ผ๋ฉด!!!
์ถ๊ฐ๋๋๊ฒ์ด ์์ต๋๋ค.
์ค์น
npm i svelte-preprocess
svelte.config.js ํ์ผ ์์ฑ ๋ฐ ์์ฑ
const sveltePreprocess = require("svelte-preprocess");
module.exports = {
preprocess: sveltePreprocess({
sass: {
sync: true,
implementation: require("sass"),
},
}),
};
alias ์ถ๊ฐ
์๊ฑฐ๋ฅผ ์ฌ์ฉํ๋ ์ด์ ๋ ๊ฒฝ๋ก๋ฅผ ์ข ๋ ํธํ๊ฒ ์ฝ๊ธฐ ์ํด์ ์ ๋๋ค.
ex) ../../../ -> ~path/
npm i @rollup/plugin-alias
rollup.config.js
export default {
...
plugins: [
...
alias({
entries: [{ find: "@", replacement: "src/" }],
}),
],
...
};
Image Loader ์ถ๊ฐ
ํ๋ก์ ํธ์์ ์ด๋ฏธ์ง๋ฅผ ์ฌ์ฉํ ์ผ์ด ์์ด์..
npm i @rollup/plugin-image
rollup.config.js
export default {
...
plugins: [
...
image()
],
...
};
.prettierrc ์ถ๊ฐ
{
"svelteSortOrder": "scripts-markup-styles",
"svelteStrictMode": true,
"svelteBracketNewLine": false,
"svelteAllowShorthand": false,
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"printWidth": 180
}
svelteSortOrder // ํ์ผ์ ๊ฐ ํ๊ทธ ์์น ์ ๋๋ค. script - html - style ์์ผ๋ก ๋ณด์ฌ์ง๊ฒ ๋์ด์. ๋ณ๊ฒฝ๋ ๊ฐ๋ฅํ๋ต๋๋ค.
npm i prettier-plugin-svelte
์ฌ๊ธฐ๊น์ง ์ธํ ๋~
๋ค์์ ๋ดฌ์!
๊ฐ์ฌํฉ๋๋ค.