Skip to content
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

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

Closed
meteorlxy opened this issue Jan 19, 2019 · 0 comments
Closed

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

meteorlxy opened this issue Jan 19, 2019 · 0 comments

Comments

@meteorlxy
Copy link
Member

meteorlxy commented Jan 19, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant