Skip to content

Resource paths now resolved relative to html file - #1

Merged
macedigital merged 1 commit into
macedigital:masterfrom
zikaari:patch-1
Jan 9, 2017
Merged

Resource paths now resolved relative to html file#1
macedigital merged 1 commit into
macedigital:masterfrom
zikaari:patch-1

Conversation

@zikaari

@zikaari zikaari commented Jan 6, 2017

Copy link
Copy Markdown
Contributor

sri generation failed in my case where I had complex directory structure like this:

myApp
|-- gulpfile.js
|-- core
|   |-- scripts
|   |   `-- main.js
|   |-- styles
|   |   `-- main.css
|   `-- index.html
`-- hosts
    |-- electron
    |   |-- scripts
    |   |   `-- main.js
    |   `-- index.html
    `-- webapp
        |-- scripts
        |   `-- main.js
        `-- index.html

Upon debugging index.js I found paths to resources were being resolved relative to gulpfile or cwd (not sure). After this patch they are now resolved relative to html file in question.

sri generation failed in my case where I had complex directory structure like this:
`
myApp
|-- gulpfile.js
|-- core
|   |-- scripts
|   |   `-- main.js
|   |-- styles
|   |   `-- main.css
|   `-- index.html
`-- hosts
    |-- electron
    |   |-- scripts
    |   |   `-- main.js
    |   `-- index.html
    `-- webapp
        |-- scripts
        |   `-- main.js
        `-- index.html
`

Upon debugging `index.js` I found paths to resources were being resolved relative to `gulpfile` or `cwd` (not sure). After this patch they are now resolved relative to `html` file in question.
@codecov-io

codecov-io commented Jan 6, 2017

Copy link
Copy Markdown

Current coverage is 100% (diff: 100%)

Merging #1 into master will not change coverage

@@           master    #1   diff @@
===================================
  Files           1     1          
  Lines          61    61          
  Methods         0     0          
  Messages        0     0          
  Branches        0     0          
===================================
  Hits           61    61          
  Misses          0     0          
  Partials        0     0          

Powered by Codecov. Last update 4ab8ff4...249f1fc

@macedigital

Copy link
Copy Markdown
Owner

@NeekSandhu, yes you're absolutely right. It's an undocumented "intended behavior" for folder structures like the one below (so no matter how deep html files are nested, referencing assets/styles/main.css works):

root-folder
|-- gulpfile.js
|-- assets
|   |-- scripts
|   |   `-- main.js
|   |-- styles
|   |   `-- main.css
`-- html
    |-- section
    |   |-- sub-section
    |   |   `-- index.html
    |   `-- index.html

In order to accommodate to your use case, I'll make some modifications, and introduce a configurable option relative: true. After doing so, relative path resolution should work as well.

If you have the time, please test it out (either from git, or wait until v1.2.0 release is out).

@macedigital
macedigital merged commit bd27a2b into macedigital:master Jan 9, 2017
@zikaari

zikaari commented Jan 10, 2017

Copy link
Copy Markdown
Contributor Author

Great, sounds good. But just out of curiosity, what kind of project uses the structure you mentioned? I've never seen that before.

In my case its because my app is delivered through iframe in browser and webview in electron.

@macedigital

macedigital commented Jan 10, 2017

Copy link
Copy Markdown
Owner

It's a result of using static site generators, e.i. Hugo, which will create nested folder structures containing 'index.html' files.

@zikaari
zikaari deleted the patch-1 branch January 10, 2017 23:08
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

Successfully merging this pull request may close these issues.

3 participants