Skip to content

Can not set specific single entry outside the src #1091

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

Closed
duduluu opened this issue Apr 8, 2018 · 2 comments
Closed

Can not set specific single entry outside the src #1091

duduluu opened this issue Apr 8, 2018 · 2 comments

Comments

@duduluu
Copy link

duduluu commented Apr 8, 2018

Version

3.0.0-beta.6

Reproduction link

https://github.com/HuijiFE/void-ui/tree/0.1

Steps to reproduce

git clone git@github.com:HuijiFE/void-ui.git
cd void-ui
git checkout 0.1
yarn
yarn serve
# or
yarn build:docs

What is expected?

Serve a entry that not in directory 'src'. (docs/main.ts)

What is actually happening?

log for serve command

 ERROR  Failed to compile with 1 errors                                                                                                                                                                                            17:24:55

This relative module was not found:

* ./src/main.ts in multi (webpack)-dev-server/client/index.js (webpack)/hot/dev-server.js ./src/main.ts
Type checking and linting in progress... 

log for build command

 ERROR  Failed to compile with 1 errors                                                                                                                                                                                            17:30:18

This relative module was not found:

* ./src/main.ts in multi ./src/main.ts

The problem occurs when there is no entry in the src.

@duduluu duduluu changed the title Can not set specific single entry for serve or build Can not set specific single entry outside the src Apr 8, 2018
@LinusBorg
Copy link
Member

Unless I'm minstaken, the serve command doesn't allow to change the entry via the command line in any way right now.

So for now, you will have to work around this by using vue.config.js and an env variable:

"serve": VUE_SERVE_DOCS=1 vue-cli-service serve",
const path = require('path')
module.exports = {
  chainWebpack: config => {
    if (process.env.VUE_SERVE_DOCS) {
      config.entry('app' ).set(path.resolve(__dirname, './docs/main.ts')
    }
  }
}

@duduluu
Copy link
Author

duduluu commented Apr 13, 2018

The set() is no available for entry.

I use clear() and add() for my project

    "serve": "VUE_SOLUTION=docs vue-cli-service serve docs/main.ts",
    "build:void": "VUE_SOLUTION=void vue-cli-service build src/VoidUI.ts --dest dist --target lib",
    "build:docs": "VUE_SOLUTION=docs vue-cli-service build docs/main.ts --dest www",
const path = require('path');

const SOLUTION = process.env.VUE_SOLUTION;

module.exports = {
  chainWebpack: config => {
    const context = config.store.get('context');
    const resolve = _path => path.resolve(context, _path);

    if (SOLUTION === 'docs') {
      config
        .entry('app')
        .clear()
        .add(resolve('docs/main.ts'));
    }
  },
}

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

3 participants