Skip to content

Commit e2c2b48

Browse files
author
Guillaume Chau
committedApr 23, 2018
feat(ui): clientAddonConfig
1 parent 132c8df commit e2c2b48

File tree

4 files changed

+42
-55
lines changed

4 files changed

+42
-55
lines changed
 

‎docs/plugin-dev-ui.md

+6-30
Original file line numberDiff line numberDiff line change
@@ -276,38 +276,14 @@ The recommended way to create a Client addon is by creating a new project using
276276
Then add a `vue.config.js` file with the following content:
277277

278278
```js
279+
const { clientAddonConfig } = require('@vue/cli-ui')
280+
279281
module.exports = {
280-
// Change the id here
281-
baseUrl: '/_addon/<client-addon-id>',
282-
// You can change the port here
283-
devBaseUrl: 'http://localhost:8042/',
284-
configureWebpack: {
285-
output: {
286-
// Important
287-
filename: 'index.js'
288-
}
289-
},
290-
// Don't extract CSS into a separate file
291-
css: {
292-
extract: false
293-
},
294-
// Remove unneeded webpack plugins
295-
chainWebpack: config => {
296-
config.plugins.delete('preload')
297-
config.plugins.delete('prefetch')
298-
config.plugins.delete('html')
299-
config.plugins.delete('split-vendor')
300-
config.plugins.delete('split-vendor-async')
301-
config.plugins.delete('split-manifest')
302-
},
303-
// Configure dev server
304-
devServer: {
305-
headers: {
306-
'Access-Control-Allow-Origin': '*'
307-
},
308-
// You can change the port here
282+
...clientAddonConfig({
283+
id: '<client-addon-id>',
284+
// Development port (default 8042)
309285
port: 8042
310-
}
286+
})
311287
}
312288
```
313289

Original file line numberDiff line numberDiff line change
@@ -1,27 +1,8 @@
1+
const { clientAddonConfig } = require('@vue/cli-ui')
2+
13
module.exports = {
2-
baseUrl: '/_addon/vue-webpack',
3-
devBaseUrl: 'http://localhost:8042/',
4-
configureWebpack: {
5-
output: {
6-
// Important
7-
filename: 'index.js'
8-
}
9-
},
10-
css: {
11-
extract: false
12-
},
13-
chainWebpack: config => {
14-
config.plugins.delete('preload')
15-
config.plugins.delete('prefetch')
16-
config.plugins.delete('html')
17-
config.plugins.delete('split-vendor')
18-
config.plugins.delete('split-vendor-async')
19-
config.plugins.delete('split-manifest')
20-
},
21-
devServer: {
22-
headers: {
23-
'Access-Control-Allow-Origin': '*'
24-
},
25-
port: 8042
26-
}
4+
...clientAddonConfig({
5+
id: 'vue-webpack'
6+
// port: 8042
7+
})
278
}

‎packages/@vue/cli-ui/index.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
exports.clientAddonConfig = function ({ id, port = 8042 }) {
2+
return {
3+
baseUrl: `/_addon/${id}`,
4+
devBaseUrl: `http://localhost:${port}/`,
5+
configureWebpack: {
6+
output: {
7+
// Important
8+
filename: 'index.js'
9+
}
10+
},
11+
css: {
12+
extract: false
13+
},
14+
chainWebpack: config => {
15+
config.plugins.delete('preload')
16+
config.plugins.delete('prefetch')
17+
config.plugins.delete('html')
18+
config.plugins.delete('split-vendor')
19+
config.plugins.delete('split-vendor-async')
20+
config.plugins.delete('split-manifest')
21+
},
22+
devServer: {
23+
headers: {
24+
'Access-Control-Allow-Origin': '*'
25+
},
26+
port
27+
}
28+
}
29+
}

‎packages/@vue/cli-ui/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "3.0.0-beta.6",
44
"author": "Guillaume Chau",
55
"license": "MIT",
6+
"main": "index.js",
67
"scripts": {
78
"serve": "vue-cli-service serve",
89
"build": "vue-cli-service build",

0 commit comments

Comments
 (0)