Skip to content

feat: add staticResourceDir option #7343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/config/index.md
Original file line number Diff line number Diff line change
@@ -96,6 +96,13 @@ Deprecated since Vue CLI 3.3, please use [`publicPath`](#publicPath) instead.
::: tip
`assetsDir` is ignored when overwriting the filename or chunkFilename from the generated assets.
:::

### staticResourceDir

- Type: `string`
- Default: `'public'`

A static resource directory for `copy-webpack-plugin`.

### indexPath

8 changes: 8 additions & 0 deletions docs/ru/config/index.md
Original file line number Diff line number Diff line change
@@ -86,6 +86,14 @@ module.exports = {
`assetsDir` игнорируется при перезаписи опций имени файла (filename) или имени фрагментов (chunkFilename) сгенерированных ресурсов.
:::


### staticResourceDir

- Type: `string`
- Default: `'public'`

A static resource directory for `copy-webpack-plugin`.

### indexPath

- Тип: `string`
7 changes: 7 additions & 0 deletions docs/zh/config/index.md
Original file line number Diff line number Diff line change
@@ -98,6 +98,13 @@ module.exports = defineConfig({
从生成的资源覆写 filename 或 chunkFilename 时,`assetsDir` 会被忽略。
:::

### staticResourceDir

- Type: `string`
- Default: `'public'`

为`copy-webpack-plugin`设置的静态资源目录.

### indexPath

- Type: `string`
2 changes: 1 addition & 1 deletion packages/@vue/cli-service/lib/config/app.js
Original file line number Diff line number Diff line change
@@ -239,7 +239,7 @@ module.exports = (api, options) => {
}

// copy static assets in public/
const publicDir = api.resolve('public')
const publicDir = api.resolve(options.staticResourceDir ?? 'public')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const PlaceholderPlugin = class PlaceholderPlugin { apply () {} }

4 changes: 4 additions & 0 deletions packages/@vue/cli-service/lib/options.js
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ const schema = createSchema(joi => joi.object({
publicPath: joi.string().allow(''),
outputDir: joi.string(),
assetsDir: joi.string().allow(''),
staticResourceDir: joi.string(),
indexPath: joi.string(),
filenameHashing: joi.boolean(),
runtimeCompiler: joi.boolean(),
@@ -94,6 +95,9 @@ exports.defaults = () => ({
// where to put static assets (js/css/img/font/...)
assetsDir: '',

// static resource dir
staticResourceDir: 'public',

// filename for index.html (relative to outputDir)
indexPath: 'index.html',

6 changes: 6 additions & 0 deletions packages/@vue/cli-service/types/ProjectOptions.d.ts
Original file line number Diff line number Diff line change
@@ -71,6 +71,12 @@ interface ProjectOptions {
* A directory (relative to `outputDir`) to nest generated static assets (js, css, img, fonts) under
*/
assetsDir?: string;
/**
* Default: `'public'`
*
* A static resource directory for `copy-webpack-plugin`.
*/
staticResourceDir?: string;
/**
* Default: `'index.html'`
*
4 changes: 4 additions & 0 deletions packages/@vue/cli-ui/locales/en.json
Original file line number Diff line number Diff line change
@@ -614,6 +614,10 @@
"label": "Assets directory",
"description": "A directory to nest generated static assets (js, css, img, fonts) under."
},
"staticResourceDir": {
"label": "Static Resource directory",
"description": "A static resource directory for 'copy-webpack-plugin'."
},
"runtimeCompiler": {
"label": "Enable runtime compiler",
"description": "This will allow you to use the template option in Vue components, but will incur around an extra 10kb payload for your app."
10 changes: 10 additions & 0 deletions packages/@vue/cli-ui/ui-defaults/config.js
Original file line number Diff line number Diff line change
@@ -43,6 +43,16 @@ module.exports = api => {
group: 'org.vue.vue-webpack.config.vue-cli.groups.general',
link: 'https://cli.vuejs.org/config/#assetsdir'
},
{
name: 'staticResourceDir',
type: 'input',
default: '',
value: data.vue && data.vue.staticResourceDir,
message: 'org.vue.vue-webpack.config.vue-cli.staticResourceDir.label',
description: 'org.vue.vue-webpack.config.vue-cli.staticResourceDir.description',
group: 'org.vue.vue-webpack.config.vue-cli.groups.general',
link: 'https://cli.vuejs.org/config/#staticResourceDir'
},
{
name: 'runtimeCompiler',
type: 'confirm',