Skip to content

Commit e6cef11

Browse files
committed
fix: workaround vue-cli
1 parent 1e43054 commit e6cef11

File tree

3 files changed

+64
-22
lines changed

3 files changed

+64
-22
lines changed

README.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default defineConfig({
3131
})
3232
```
3333

34-
Example: [`examples/vite/`](./examples/vite/)
34+
Example: [`examples/vite`](./examples/vite/)
3535

3636
<br></details>
3737

@@ -40,10 +40,23 @@ Example: [`examples/vite/`](./examples/vite/)
4040

4141
```ts
4242
// webpack.config.js
43+
const { VueLoaderPlugin } = require('vue-loader')
44+
const Markdown = require('unplugin-vue-markdown/webpack')
45+
4346
module.exports = {
4447
/* ... */
48+
module: {
49+
rules: [
50+
// ... other rules
51+
{
52+
test: /\.(vue|md)$/,
53+
loader: 'vue-loader'
54+
}
55+
]
56+
},
4557
plugins: [
46-
require('unplugin-vue-markdown/webpack')({ /* options */ })
58+
new VueLoaderPlugin(),
59+
Markdown({ /* options */ })
4760
]
4861
}
4962
```
@@ -55,20 +68,28 @@ module.exports = {
5568

5669
```ts
5770
// vue.config.js
71+
const Markdown = require('unplugin-vue-markdown/webpack')
72+
5873
module.exports = {
59-
configureWebpack: {
60-
plugins: [
61-
require('unplugin-vue-markdown/webpack')({ /* options */ }),
62-
],
63-
},
74+
parallel: false, // Disable thread-loader which will cause errors, we are still investigating the root cause
6475
chainWebpack: (config) => {
6576
config.module
6677
.rule('vue')
6778
.test(/\.(vue|md)$/) // <-- allows Vue to compile Markdown files
79+
80+
config
81+
.plugin('markdown')
82+
.use(Markdown({
83+
markdownItUses: [
84+
prism,
85+
],
86+
}))
6887
},
6988
}
7089
```
7190

91+
Example: [`examples/vue-cli`](./examples/vue-cli/)
92+
7293
<br></details>
7394

7495
## Import Markdown as Vue components
@@ -160,7 +181,7 @@ npm i @unhead/vue
160181
```js
161182
// vite.config.js
162183
import Vue from '@vitejs/plugin-vue'
163-
import Markdown from 'unplugin-vue-markdown'
184+
import Markdown from 'unplugin-vue-markdown/vite'
164185

165186
export default {
166187
plugins: [

examples/vite/README.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default defineConfig({
3131
})
3232
```
3333

34-
Example: [`examples/vite/`](./examples/vite/)
34+
Example: [`examples/vite`](./examples/vite/)
3535

3636
<br></details>
3737

@@ -40,10 +40,23 @@ Example: [`examples/vite/`](./examples/vite/)
4040

4141
```ts
4242
// webpack.config.js
43+
const { VueLoaderPlugin } = require('vue-loader')
44+
const Markdown = require('unplugin-vue-markdown/webpack')
45+
4346
module.exports = {
4447
/* ... */
48+
module: {
49+
rules: [
50+
// ... other rules
51+
{
52+
test: /\.(vue|md)$/,
53+
loader: 'vue-loader'
54+
}
55+
]
56+
},
4557
plugins: [
46-
require('unplugin-vue-markdown/webpack')({ /* options */ })
58+
new VueLoaderPlugin(),
59+
Markdown({ /* options */ })
4760
]
4861
}
4962
```
@@ -55,20 +68,28 @@ module.exports = {
5568

5669
```ts
5770
// vue.config.js
71+
const Markdown = require('unplugin-vue-markdown/webpack')
72+
5873
module.exports = {
59-
configureWebpack: {
60-
plugins: [
61-
require('unplugin-vue-markdown/webpack')({ /* options */ }),
62-
],
63-
},
74+
parallel: false, // Disable thread-loader which will cause errors, we are still investigating the root cause
6475
chainWebpack: (config) => {
6576
config.module
6677
.rule('vue')
6778
.test(/\.(vue|md)$/) // <-- allows Vue to compile Markdown files
79+
80+
config
81+
.plugin('markdown')
82+
.use(Markdown({
83+
markdownItUses: [
84+
prism,
85+
],
86+
}))
6887
},
6988
}
7089
```
7190

91+
Example: [`examples/vue-cli`](./examples/vue-cli/)
92+
7293
<br></details>
7394

7495
## Import Markdown as Vue components
@@ -160,7 +181,7 @@ npm i @unhead/vue
160181
```js
161182
// vite.config.js
162183
import Vue from '@vitejs/plugin-vue'
163-
import Markdown from 'unplugin-vue-markdown'
184+
import Markdown from 'unplugin-vue-markdown/vite'
164185

165186
export default {
166187
plugins: [

examples/vue-cli/vue.config.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ const prism = require('markdown-it-prism')
44

55
module.exports = defineConfig({
66
transpileDependencies: true,
7+
parallel: false,
78
chainWebpack: (config) => {
89
config.module
910
.rule('vue')
1011
.test(/\.(vue|md)$/)
11-
},
12-
configureWebpack(config) {
13-
config.plugins.unshift(
14-
Markdown({
12+
13+
config
14+
.plugin('markdown')
15+
.use(Markdown({
1516
markdownItUses: [
1617
prism,
1718
],
18-
}),
19-
)
19+
}))
2020
},
2121
})

0 commit comments

Comments
 (0)