Skip to content

[Feature Request] Allow theme packages use a sub directory #1204

Closed
@meteorlxy

Description

@meteorlxy

Feature request

What problem does this feature solve?

Currently, we can build a theme package following https://vuepress.vuejs.org/theme/writing-a-theme.html#directory-structure

We have to set the main field of package.json to index.js.

If we could allow the main field be something like lib/index.js?

i.e. putting all theme files into a sub directory lib:

themePackageRoot
├── lib # put all the theme files in
│   ├── global-components
│   │   └── xxx.vue
│   ├── components
│   │   └── xxx.vue
│   ├── layouts
│   │   ├── Layout.vue
│   │   └── 404.vue
│   ├── styles
│   │   ├── index.styl
│   │   └── palette.styl
│   ├── templates
│   │   ├── dev.html
│   │   └── ssr.html
│   ├── index.js
│   └── enhanceApp.js
├── docs # and some other sub directory that not related to the theme files
└── package.json # point "main" to "lib/index.js"

How should this be implemented in your opinion?

I find related code here:

if (fromDep) {
const pkgPath = require.resolve(`${name}/package.json`)
return path.parse(pkgPath).dir

Change require.resolve(`${name}/package.json`) to require.resolve(name) may help, but I'm not sure if it will cause any side effects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions