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

wrong dir resolvepath #2

Closed
luanwulin opened this issue Nov 26, 2017 · 5 comments
Closed

wrong dir resolvepath #2

luanwulin opened this issue Nov 26, 2017 · 5 comments

Comments

@luanwulin
Copy link

luanwulin commented Nov 26, 2017

in my situation i don't set next folder at the root path.

here is my project path example
approot
--app
----next
------components
--------login
----------img
------------a.jpg
----------login.js
------static
------pages
------styles

My babelrc:
{ "plugins": [ [ "import-static-files", { "baseDir": "app/next/static/", "baseUri": "http://your.cdn.address" } ] ] }

i build this project at the root path
next build app/next

i get img path in login.js like this
import logoImg from './img/a.jpg'
then i'll get the result

var logoImg ='http://your.cdn.address/app/next/static/app/next/components/login/logo/img/a.jpg';
it's absolutely wrong,how can i fix it?

This was referenced Nov 26, 2017
@mergebandit
Copy link

I'm getting something similar.

With a baseDir of src/static, and the following import:

import FooImg from './images/foo.png`

the file ends up being placed in:

/src/static/src/lib/clientSchema/mockdata/images/foo.png

Based on the documentation, I would expect this to be dropped into /src/static/foo-[hash].png

@ahalimkara
Copy link
Owner

Is hash option true?

{"hash": true}

@mergebandit
Copy link

Ah, no, but even in that case your example shows an import of ‘/path/to/file.png’ with a distributed path of just ‘/static/file.png’

I was not expecting this to copy my entire folder structure to /static - I’d argue the primary use case would be to not copy the entire dir structure and expose that to the world.

If the asset is automatically moved and the src references the correct path, I shouldn’t care if your plugin puts 104837 assets in the root of my /static folder

@ahalimkara
Copy link
Owner

/path/to/file.png will be /static/path/to/file.png as it writes in example.

It should copy entire directory structure to prevent file name conflict, /path/to/file.png and /path/to/subfolder/file.png etc. If you don't want to copy directory structure then you should set hash option to true.

@mergebandit
Copy link

👍👍

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