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

inserting body element and script into iframe src html document #330

Closed
rkoberg opened this issue Nov 15, 2014 · 7 comments · May be fixed by tobybellwood/govstrap#4
Closed

inserting body element and script into iframe src html document #330

rkoberg opened this issue Nov 15, 2014 · 7 comments · May be fixed by tobybellwood/govstrap#4

Comments

@rkoberg
Copy link

rkoberg commented Nov 15, 2014

Is there some way to stop/ignore html files loaded in iframes? I am using this from the gulp-angular-generator. I have tried several options. The files that get loaded are from a directory not watched by anything -- just served.

In this screen grab you will a body element and script that do not exist in the src:
screen shot 2014-11-14 at 5 08 07 pm

The server looks like:

function browserSyncInit(baseDir, files, browser) {
  browser = browser === undefined ? 'default' : browser;

  var routes = null;
  if(baseDir === 'src' || (util.isArray(baseDir) && baseDir.indexOf('src') !== -1)) {
    routes = {
      // Should be '/bower_components': '../bower_components'
      // Waiting for https://github.com/shakyShane/browser-sync/issues/308
      '/bower_components': 'bower_components'
    };
  }

  browserSync.instance = browserSync.init(files, {
    open: false,
    notify: false,
    host: "tmcdev.psoc.dev",
    codeSync: false,
    ghostMode: false,
    startPath: '/index.html',
    server: {
      baseDir: baseDir,
      middleware: [
        modRewrite([
          '!\\.\\w+$ /index.html [L]'
        ])
      ],
      routes: routes
    },
    browser: browser
  });
}

gulp.task('serve', ['watch'], function () {
  browserSyncInit([
    'src',
    '.tmp'
  ], [
    '.tmp/{app,components}/**/*.css',
    'src/assets/images/**/*',
    'src/*.html',
    'src/{app,components}/**/*.html',
    'src/{app,components}/**/*.js'
  ]);
});

Watch looks like:

gulp.task('watch', ['styles'] ,function () {
  gulp.watch('src/{app,components}/**/*.scss', ['styles']);
  gulp.watch('src/{app,components}/**/*.js', ['scripts']);
  gulp.watch('src/assets/images/**/*', ['images']);
  gulp.watch('bower.json', ['wiredep']);
});
@rkoberg
Copy link
Author

rkoberg commented Nov 15, 2014

The body gets put in with gulp-connect too, so that part is not part of this bug/feature request.

I am able to turn off gulp-connect's livereload JS insertions.

@shakyShane
Copy link
Contributor

Hi - thanks for the details.

I've been looking at this recently and I'm leaning towards the idea of providing more options regarding the snippet injection.

One of them will be something like excludePaths where you could say "don't touch files that match this pattern". Maybe something like this:

snippet: {
    excludePaths: ["app/templates/*.html"]
}

Do you think that would solve your issue?

@rkoberg
Copy link
Author

rkoberg commented Nov 15, 2014

Sure, that would do it.

@shakyShane
Copy link
Contributor

Ok, it's happening.

You'll be able to do either

snippet: {
    excludePaths: ["app/templates/*.html"]
}

or, which may actually be more useful, there'll also be includePaths. The following example will ignore everything other than html files in app

snippet: {
    includePaths: ["app/*.html"]
}

@shakyShane
Copy link
Contributor

@shakyShane
Copy link
Contributor

@rkoberg
Copy link
Author

rkoberg commented Nov 16, 2014

Great, thanks for the quick work!

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 a pull request may close this issue.

2 participants