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

Config source dir #1134

Closed
ieshan opened this Issue Apr 15, 2018 · 16 comments

Comments

Projects
None yet
@ieshan
Copy link

ieshan commented Apr 15, 2018

What problem does this feature solve?

There should be option in vue.config.js to change the 'src' dir to something else.

What does the proposed API look like?

module.exports = {
sourceDir: "client"
};

@Pymous

This comment has been minimized.

Copy link

Pymous commented Apr 16, 2018

You can, just create a vue.config.js file, and configure it like that :

  lintOnSave: true,
  configureWebpack: {
    output: {
      path: __dirname + '/dist/client'
    },
    resolve: {
      alias: {
        '@': __dirname + '/src/client'
      }
    },
    entry: {
      app: './src/client/main.js'
    }
  }
}```
@cj

This comment has been minimized.

Copy link

cj commented Apr 20, 2018

@Pymous I agree with @ieshan, it would be nice just to set the sourceDir, or how poi does it by just specifying the entry file https://poi.js.org/options.html#entry

@Pymous

This comment has been minimized.

Copy link

Pymous commented Apr 20, 2018

It is possible, look at the snippet 😀

But I agree that it could be made more clear somewhere in the doc !

@cj

This comment has been minimized.

Copy link

cj commented Apr 20, 2018

@Pymous I know it's possible using vue.config.js, I just think it should be made an option as other cli's like nuxt, poi etc... do 😄

@cj

This comment has been minimized.

Copy link

cj commented Apr 25, 2018

@Pymous you also have to add these to your config https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-plugin-eslint/index.js#L9 https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-plugin-typescript/lib/tslint.js#L78 https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-plugin-typescript/index.js#L23. So it's not just as simple as your snippet above. Making these use a variable and allowing you to just set sourceDir would be a nice addition IMO.

@yyx990803

This comment has been minimized.

Copy link
Member

yyx990803 commented Apr 27, 2018

There will not be a first-class option for this because we prefer all Vue CLI projects to have a consistent, standard directory structure. Using a different directory name is only a matter of personal taste, so if you insist on changing that, you are on your own.

@yyx990803 yyx990803 closed this Apr 27, 2018

@azjezz

This comment has been minimized.

Copy link

azjezz commented Sep 6, 2018

i had the same problem, i'm only using vue for front-end with zend expressive ( php ) on the back end, all modern php projects use the src/ directory to point to the source directory and public/ to the public directory, so i was looking for a way to change to source directory to assets/ and the output directory to public/assets, i ended up using @Pymous method. but i think it would be better if vue had an option to change the source directory like @ieshan mentioned.

@sam3d

This comment has been minimized.

Copy link

sam3d commented Nov 27, 2018

@yyx990803 I would like to kindly request that you reconsider your position.

One of the core tenants of Vue CLI 3 is that you can go an incredibly long way without having to eject.

Many people build Vue projects as subcomponents of other, larger projects. Usually these are servers of many different languages and frameworks; often at least partially responsible for serving the generated dist directory (something that you can configure, as there has been a clearly recognised need to change the output of build files).

The src directory may also be used by these frameworks and languages for different purposes. For any particular project, it may make sense that the client uses src for their serverside code, and wish to rename their src to client to better distinguish these, for example.

This lack of configurability feels weird and inconsistent. src works well as a default but it doesn't seem take into account the scope of which Vue projects often exist: not as standalone projects but as a smaller part of larger projects. Creating an entirely new subdirectory within an existing project for a Vue project and then also having an src and dist and new package.json and every other required file again is an unwieldy solution to these problems.

@onyijne

This comment has been minimized.

Copy link

onyijne commented Nov 30, 2018

@sam3d just spoke my mind, after going through several docs on the internet on how to rename src folder to client.
I use Onsen-UI, Vue with Yii framework and I have configured the project to share a single package.json file, (as I configured Yii to use npm for assets management instead of Yii's built-in assets management), but could not tell Vue where to get its source code from, @yyx990803 kindly reconsider your stand.

@sam3d

This comment has been minimized.

Copy link

sam3d commented Nov 30, 2018

I've started work on a package that attempts to emulate the desired native behaviour as closely as possible.

$ vue add source-dir
// vue.config.js
module.exports = {
    pluginOptions: {
        sourceDir: "client"
    }
}

https://github.com/sam3d/vue-source-dir

This should be a first-class option though, and I would rather this was treated as a stopgap implementation as opposed to a long-term solution.

@douglasg14b

This comment has been minimized.

Copy link

douglasg14b commented Dec 31, 2018

Using a different directory name is only a matter of personal taste, so if you insist on changing that, you are on your own.

Isn't that literally the entire point of being able to configure via vue.config.js? Isn't the current default also a matter of personal taste, just that it is someone else's based on their common environment?

As an example, you don't want an awkward src directory at the root of an asp.net application, that's just bad form.

@AlexandreBonaventure

This comment has been minimized.

Copy link
Contributor

AlexandreBonaventure commented Jan 19, 2019

@yyx990803
I know vue-cli is more leaning towards SPAs projects, but since vue-cli provides build with target lib, I would have expected it suited for library development as well.

For one of the library I am developing I was using poi, and I wanted to switch to 'vue-cli' to both build the library but serve and build the example pages for instance.

As a plugin developer for Vue, it makes sense for me to use vue-cli because it provides everything I need without the hassle of maintaining my package.json for serving, building, babel support, unit tests with babel support...
The lack of being able to use vue-cli-service with different configuration and choose the config src directory makes it almost unusable for this purpose (If you don't wanna spend much effort to do it manually)
Would you then recommend to always use poi in those circumstances ? Just curious about the whole scope of the service. Maybe it should be stated clearly in the documentation if so.
Thanks

img

@cawoodm

This comment has been minimized.

Copy link

cawoodm commented Feb 18, 2019

Sorry to comment post-mortem but it seems relevant: Why does vue build only work when run from inside the src/ directory (i.e. you can't run it in the parent directory because it can't find a Valid entry file) and then create a dist/ subdirectory inside the src/ directory? There seems to be no way to get src/ and dist/ to be siblings...

@sodatea

This comment has been minimized.

Copy link
Member

sodatea commented Feb 18, 2019

@cawoodm vue build is not the same as npm run build.

@ansien12

This comment has been minimized.

Copy link

ansien12 commented Apr 19, 2019

Can this please be changed already? Every modern PHP framework already uses the src directory. Making it close to impossible to use vue-cli without jumping trough 20 hoops.

@Akryum

This comment has been minimized.

Copy link
Member

Akryum commented Apr 19, 2019

@ansien12 Did you try creating the vue project in a subfolder or a sibling folder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.