Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

output paths should be relative to source paths #12

Closed
bendavis78 opened this issue Nov 10, 2014 · 15 comments
Closed

output paths should be relative to source paths #12

bendavis78 opened this issue Nov 10, 2014 · 15 comments

Comments

@bendavis78
Copy link

Take this directory structure for example:

src/index.html
src/foo/bar.html
src/baz/qux/corge.html

When you have a task like this:

gulp.task('build-vulcanize', function() {
  return gulp.src('src/**/*.html')
    .pipe(vulcanize({
      dest: 'build',
      csp: true,
      inline: false
    }));
});

It puts all output files under the build directory, instead of in their respective folders:

build/index.html
build/bar.html
build/corge.html
@sindresorhus
Copy link
Owner

// @ragingwind

@ragingwind
Copy link
Contributor

@sindresorhus I think, It would be good if dest option will be removed. We can use gulp.dest instead of. also gulp.rename

@sindresorhus
Copy link
Owner

@ragingwind The dest option is used to calculate the relative paths in the actual source (which isn't possible without it AFAIK) and has nothing to do with outputting the files:

options.output = path.join(options.dest, path.basename(file.path));

@ragingwind
Copy link
Contributor

options.output would be ignored while file writing If outputSrc(outputHandler) was passed. (they have changed the name to outputHandler). we don't have to pass options.output If this plugin supports only stream out. (this plugin pass outputSrc option to vulcanize always).

@sindresorhus
Copy link
Owner

Oh, I thought options.output was used to calculate relative paths, but if it's not used I guess we can remove the dest option, which would be really nice.

I guess we should also change outputSrc to outputHandler then.

// @azakus In case we're missing something.

@ragingwind
Copy link
Contributor

ok. I'll make a new PR for this.

@ebidel
Copy link
Contributor

ebidel commented Nov 18, 2014

cc @brendankenny

@ragingwind
Copy link
Contributor

@sindresorhus @azakus Sorry. I have misunderstood, output option must be passed to vulcanize that used to calculated relative paths in vulcanized html. I had concerned a path of vulcanized html's path. To some extent, user should be passed vulcanize options If it seems to be not gulp way. And I'll push a PR this issue with grunt-vulcanize test fixtures. please review that.

@bendavis78
Copy link
Author

I was curious to see why gulp-vulcanize even needed to write anything to the filesystem (as opposed to just using vynyl). I went ahead and refactored the plugin to do this -- it has the added benefit of fixing this bug, and doesn't leave behind unecessary dot-files. I'm not sure whether or not this breaks any features, but it seems to work for my use cases. https://github.com/bendavis78/gulp-vulcanize/blob/refactor/index.js

@ragingwind
Copy link
Contributor

@bendavis78 Did you remove that bendavis78@f3d1f36#diff-168726dbe96b3ce427e7fedce31bb0bcL28 with unused modules? Yes It's almost same with my version.

My concern is that in case of vulcanize couldn't calculate relative path correctly if grunt-vulcanize doesn't pass output options to vuclanize. case is that https://github.com/Polymer/grunt-vulcanize/blob/master/test/expected/csp/vulcanized.html#L4

in your case(or cases that doesn't need to changed). have no problems(maybe). <script src="../bower_components/..."></script> works well

\bower_components
\src\index.html
\build\vulcanized.html
\src\statics
\src\index.html
\build\statics // copied from src
\build\vulcanized.html

but we have to consider abspath(maybe) option and the all of other cases see below. If we don't pass output path it would be not generated script src path correctly. vulcanize try to calculate relative path by `/fixtures/vulcanized.html'

\fixtures\bower_components\
\fixtures\index.html  `<script src="bower_components/..."></script>`
\temp\vulcanized.html scirpt src should be changed to  `<script src="../fixtures/bower_components/..."></script>`

@bendavis78
Copy link
Author

@ragingwind, I'm confused -- are we talking about grunt or gulp?

@bendavis78
Copy link
Author

Sorry, I was just looking at your link and got confused. I think I see what you mean by the relative path not being considered in my version. Perhaps vulcanize needs a patch to allow for this option while still allowing the use of buffers only. I may dig into vulcanize a little more to see what's possible.

@ragingwind
Copy link
Contributor

@bendavis78 absolutely gulp. What point is that makes you confuse? To give you an idea. I use a testcase of grunt-vulcanize for gulp-vulcanize

@sindresorhus
Copy link
Owner

I was curious to see why gulp-vulcanize even needed to write anything to the filesystem (as opposed to just using vynyl).

Because Vulcanize only recently supported string in/out.

ragingwind added a commit to ragingwind/gulp-vulcanize that referenced this issue Nov 22, 2014
ragingwind added a commit to ragingwind/gulp-vulcanize that referenced this issue Nov 22, 2014
sindresorhus pushed a commit that referenced this issue Nov 23, 2014
@sindresorhus
Copy link
Owner

Fixed by 2179cef

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants