Skip to content

Commit 8c55e55

Browse files
fix: add mdsvex and more as builtin plugins
1 parent 32f5b35 commit 8c55e55

File tree

5 files changed

+118
-1
lines changed

5 files changed

+118
-1
lines changed

lib/plugins/mdsvex/index.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { mdsvex } from 'mdsvex'
2+
const extension = ['.md', '.svx', '.svelte']
3+
4+
/** @type {import('roxi')['RoxiPlugin']} */
5+
module.exports.default = {
6+
name: 'mdsvex',
7+
hooks: [
8+
{
9+
event: 'start',
10+
action: app => app.config.mdsvex = {}, //provide an mdsvex object for developers to modify
11+
},
12+
{
13+
event: 'before:bundle',
14+
action: (app, params) => {
15+
app.merge({
16+
config: {
17+
svelte: {
18+
preprocess: [
19+
mdsvex({
20+
...app.config.mdsvex,
21+
...params
22+
})
23+
],
24+
extensions: params.extension
25+
|| app.config.svelte.extensions
26+
|| app.config.mdsvex.extension
27+
|| extension
28+
}
29+
}
30+
})
31+
}
32+
}
33+
]
34+
}

lib/plugins/mdsvex/options.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports.default = [
2+
{
3+
type: 'multiSelect',
4+
name: 'extensions',
5+
message: 'Comma separated extensions to use for markdown',
6+
hint: 'More extensions can be added in _roxi/roxi.config.yaml',
7+
initial: ['.md', '.svx'],
8+
choices: ['.md', '.svx']
9+
}
10+
]

lib/plugins/postcss/index.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
export default {
2+
dependencies: {
3+
'preprocess': () => import('../preprocess')
4+
},
5+
hooks: [
6+
{
7+
event: 'start',
8+
action: async (app, params) => {
9+
app.merge({
10+
config: {
11+
postcss: {
12+
plugins: []
13+
}
14+
}
15+
})
16+
}
17+
},
18+
{
19+
event: 'before:bundle',
20+
action: async (app, params) => {
21+
const postcss = (await import('rollup-plugin-postcss')).default
22+
const autoPreprocess = (await import('svelte-preprocess')).default
23+
const postcssImport = (await import('postcss-import')).default
24+
const postcssCfg = { plugins: [postcssImport()] }
25+
26+
app.merge({
27+
config: {
28+
rollup: {
29+
plugins: [
30+
postcss(postcssCfg)
31+
]
32+
},
33+
svelte: {
34+
preprocess: [
35+
autoPreprocess({
36+
postcss: postcssCfg,
37+
defaults: { style: 'postcss' }
38+
})
39+
]
40+
}
41+
}
42+
})
43+
}
44+
}
45+
]
46+
}
47+

lib/plugins/preprocess/index.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export default {
2+
hooks: [
3+
{
4+
condition: 'start',
5+
action: app => app.config.autoPreprocess = {}
6+
},
7+
{
8+
condition: 'before:bundle',
9+
action: async (app, params) => {
10+
const autoPreprocess = (await import('svelte-preprocess')).default
11+
12+
app.merge({
13+
config: {
14+
svelte: {
15+
preprocess: [
16+
autoPreprocess(app.config.autoPreprocess)
17+
]
18+
}
19+
}
20+
})
21+
}
22+
}
23+
]
24+
}

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "roxi",
3-
"version": "1.3.0",
3+
"version": "1.4.0",
44
"description": "The framework that gets your rocks off",
55
"bin": "lib/cli.js",
66
"main": "roxi.js",
@@ -31,6 +31,7 @@
3131
"express": "^4.17.1",
3232
"fs-extra": "^9.0.1",
3333
"jsondiffpatch": "^0.4.1",
34+
"mdsvex": "^0.8.8",
3435
"node-html-parser": "^1.2.20",
3536
"nollup": "^0.13.11",
3637
"ora": "^4.0.4",
@@ -43,6 +44,7 @@
4344
"spassr": "^2.0.0",
4445
"svelte": "^3.23.2",
4546
"svelte-hmr": "^0.10.2",
47+
"svelte-preprocess": "^4.3.1",
4648
"svite": "^0.5.0",
4749
"terminal-link": "^2.1.1",
4850
"tree-kill": "^1.2.2",

0 commit comments

Comments
 (0)