Skip to content

Building with "--target lib" ignores public folder #5536

Open
@Robin-Hoodie

Description

@Robin-Hoodie

Version

4.4.1

Reproduction link

https://github.com/Robin-Hoodie/vue-target-lib-public-folder

Environment info

Environment Info:

  System:
    OS: macOS 10.15.4
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  Binaries:
    Node: 13.6.0 - ~/.nvm/versions/node/v13.6.0/bin/node
    Yarn: 1.22.4 - ~/.yarn/bin/yarn
    npm: 6.14.5 - ~/.nvm/versions/node/v13.6.0/bin/npm
  Browsers:
    Chrome: 83.0.4103.61
    Firefox: 76.0.1
    Safari: 13.1
  npmGlobalPackages:
    @vue/cli: 4.3.1

Steps to reproduce

  • Clone repo
  • Run yarn build --target lib

What is expected?

The image in public/public-images/public-image.png is copied to the dist folder

What is actually happening?

Nothing in the public folder is copied


I realize that when building a library, the default files in the public folder are not relevant and is okay behaviour in most cases.
However, for my case, I needed some images in the public folder as I didn't want their file names to be hashed. On the other hand, I didn't want to turn off file name hashing (as an option in vue.config.js) either.

I eventually solved this by tapping into the webpack config and copying over the public folder myself in there.

I don't think this is expected behaviour however as:

  • The documentation at https://cli.vuejs.org/guide/build-target does not mention anything about NOT copying the "public" folders content when running the build command with target -- lib
  • A github issue I found on inspecting the webpack config (trying to find how the CopyWebpackPlugin was configured for builds with target --lib), explicitly mentions there is no difference between building with or without target --lib apart from the entry and output options: Inspect should accept a --target #1250 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions