generator-angular icon indicating copy to clipboard operation
generator-angular copied to clipboard

sass-bootstrap includes unnecessary js (from bootstrap and jquery)

Open lanterndev opened this issue 11 years ago • 20 comments

If you answer 'yes' to compass and bootstrap, you end up with the 'sass-bootstrap' bower component. Besides all the bootstrap stylesheets translated into sass, this library also includes all the bootstrap javascript, as well as a dependency on jquery. But many angular apps don't want any of the bootstrap javascript or jquery. Either they only need the bootstrap styles, or they use https://github.com/angular-ui/bootstrap if they need the js components.

Maybe it doesn't hurt too much to depend on sass-bootstrap even with the unnecessary js, but eventually it'd be better to use a library that only included the sass. What do you think?

lanterndev avatar Jan 05 '14 19:01 lanterndev

I agree, it should be separate components, but this should be fixed on the sass-bootstrap issue tracker, so open a ticket over there ;)

sindresorhus avatar Jan 06 '14 13:01 sindresorhus

I already tried that but no love, unfortunately. See jlong/sass-bootstrap#90. Any other ideas?

lanterndev avatar Jan 06 '14 16:01 lanterndev

If anyone would like to maintain it you could create separate packages for it and put it on Bower.

sindresorhus avatar Jan 06 '14 17:01 sindresorhus

Thanks for reopening.

Unfortunately I don't have the bandwidth to take on maintaining a new package at the moment. What's the best way to put the word out to the community so someone else can?

lanterndev avatar Jan 06 '14 17:01 lanterndev

this library also includes all the bootstrap javascript, as well as a dependency on jquery. But many angular apps don't want any of the bootstrap javascript or jquery. 

But some do and removing them is as simple as deleting the lines in index.html

Either they only need the bootstrap styles or they use https://github.com/angular-ui/bootstrap if they need the js components

UI-Bootstrap isn't a 1:1 translation. So people might want to use the JS components. If they want UI-Bootstrap then they can add it like any other dependency.

As soon as the 'which sass-bootstrap is the official one' issue is resolved it should make things easier.

eddiemonge avatar Jan 06 '14 20:01 eddiemonge

I think this is also related to https://github.com/yeoman/generator-angular/issues/522 in which alot of useless CSS/JS is included with every package. I like the idea of automatically adding to your index.html the CSS and JS but it seems there's a lot of waste and grunt-bower-install is too early to be introduced.

it's adding CSS files when I include them in SASS and then customise by altering variables, so I've had to remove bower:css... and now it looks like I'll have to remove bower:js as well as it's including jquery, boostrap JS too :s

intellix avatar Jan 15 '14 11:01 intellix

I agree this is an odd bug. I blame Bootstrap since it bundles JS and CSS together when it should have them separately since you dont need the JS for the CSS but the JS can use the CSS but doesn't have to. I honestly don't know how to handle this without take Bootstrap out (but then what good CSS framework should be offered) or don't have Bootstrap in Bower but included manually (but then you lose the power to be able to easily remove it with bower uninstall --save bootstrap...).

Open to suggestions

eddiemonge avatar Mar 07 '14 22:03 eddiemonge

i believe this can be fixed in your Gruntfile, now that grunt-bower-install has been updated in 6a1678953bce069b4ac79f68e0959e80cbdbaa3f. you should be able to specify exclude patterns in your bowerInstall task. it works for me, although i manually updated my grunt-bower-install to 1.3...

entronic avatar Mar 17 '14 00:03 entronic

@entronic want to submit a PR to fix this?

eddiemonge avatar Mar 28 '14 00:03 eddiemonge

@skivvies @entronic @intellix want to try @mrhooray PR to see if it fixes the problem? : https://github.com/yeoman/generator-angular/pull/631

eddiemonge avatar Mar 28 '14 23:03 eddiemonge

@mrhooray bootstrap-sass-official does depend on jQuery. If you don't include it, then you get JS errors.

eddiemonge avatar May 06 '14 22:05 eddiemonge

simply config gruntfile

wiredep: {
  options: {
    cwd: '<%= yeoman.app %>',
    exclude: ['bower_components/bootstrap-sass-official/assets/javascripts/{,*/}*.{js}']
  },
  ...
},
...

hardywu avatar Sep 30 '14 03:09 hardywu

Exclude option value can be shorter:

exclude: ['bower_components/bootstrap-sass-official/assets/javascripts']

peterblazejewicz avatar Nov 29 '14 16:11 peterblazejewicz

Was searching where to put the exclude so:

wiredep: {
      app: {
        src: ['<%= yeoman.app %>/index.html'],
        exclude: ['bower_components/bootstrap-sass-official/assets/javascripts'],
        ignorePath:  /\.\.\//
      },
      sass: {
        src: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
        ignorePath: /(\.\.\/){1,2}bower_components\//
      }      
    }

Virviil avatar Nov 30 '14 22:11 Virviil

@mrhooray, until someone maintains a dedicated package for it, you can just add jquery to your excludes:

wiredep: {
      app: {
        src: ['<%= yeoman.app %>/index.html'],
        ignorePath:  /\.\.\//,
        exclude: [
          'bower_components/bootstrap-sass-official/assets/javascripts',
          'bower_components/jquery'
        ]
      },
      sass: {
        src: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
        ignorePath: /(\.\.\/){1,2}bower_components\//
      }      
    }

xml avatar Dec 15 '14 07:12 xml

thanks for the config guys

tangorri avatar Dec 29 '14 15:12 tangorri

Is there any desire for this exclude config to be the default in generator-angular? Thinking a PR to add this config in might be useful?

mattdarveniza avatar Apr 08 '15 01:04 mattdarveniza

I have a similar issue, I have a project built off yeoman which uses bootstrap, but my main css has the entire boostrap file included with loads of css I don't need. So trying to figure out the best way to take out all the unused css to cut down on file size for production.

mtsweir avatar Oct 10 '15 04:10 mtsweir

I was looking for a way to remove parts of bootstrap-sass. You can edit bower.json and edit the overrides of bootstrap-sass. Very useful doc about this here :
https://roots.io/using-bootstrap-with-bower-how-to-override-bower-packages/

abumalick avatar Feb 25 '16 15:02 abumalick

To exclude jquery I've added 'bower_components/jquery/dist' to excludes. 'bower_components/jquery' doesn't worked for me.

lifeisfoo avatar Aug 17 '16 11:08 lifeisfoo