Angular 6 Library using bootstrap












5















I am creating an angular library in an angular project using angular 6 library feature https://github.com/angular/angular-cli/wiki/stories-create-library



I am creating few reusable components via this which can be resused across my projects.. somehting like name component , phone number component etc..
I created the components..
but I am not sure how to include bootstrap in the library projects? The projects which consume my library will install bootstrap I guess...
How do i approach this?



This is not on how to add bootstrap to Angular application.. This is diffent and I am seeking opinion on how to add to Angular Library... Should I package it with my library or Should it be a peerdependency? If its a peer dependency , how do i go about it?



I have to use some mixins from bootstrap in the library project as well.. How to get them in the library project?










share|improve this question




















  • 2





    Possible duplicate of How to use Bootstrap in an Angular project?

    – MassiveCodes
    Jan 16 at 19:03






  • 1





    Go for ng-bootstrap: you will have some convenient bootstrap components

    – Al-un
    Jan 16 at 19:03











  • This is particulary about Angular Library project..Not about Angular project...

    – Jocket
    Jan 16 at 19:04











  • is this what are you looking for?

    – Gaspar
    Jan 16 at 19:54













  • Not really..I am past this portion..its working..Now its more on specific problem about bootstrap and library

    – Jocket
    Jan 16 at 22:12
















5















I am creating an angular library in an angular project using angular 6 library feature https://github.com/angular/angular-cli/wiki/stories-create-library



I am creating few reusable components via this which can be resused across my projects.. somehting like name component , phone number component etc..
I created the components..
but I am not sure how to include bootstrap in the library projects? The projects which consume my library will install bootstrap I guess...
How do i approach this?



This is not on how to add bootstrap to Angular application.. This is diffent and I am seeking opinion on how to add to Angular Library... Should I package it with my library or Should it be a peerdependency? If its a peer dependency , how do i go about it?



I have to use some mixins from bootstrap in the library project as well.. How to get them in the library project?










share|improve this question




















  • 2





    Possible duplicate of How to use Bootstrap in an Angular project?

    – MassiveCodes
    Jan 16 at 19:03






  • 1





    Go for ng-bootstrap: you will have some convenient bootstrap components

    – Al-un
    Jan 16 at 19:03











  • This is particulary about Angular Library project..Not about Angular project...

    – Jocket
    Jan 16 at 19:04











  • is this what are you looking for?

    – Gaspar
    Jan 16 at 19:54













  • Not really..I am past this portion..its working..Now its more on specific problem about bootstrap and library

    – Jocket
    Jan 16 at 22:12














5












5








5


1






I am creating an angular library in an angular project using angular 6 library feature https://github.com/angular/angular-cli/wiki/stories-create-library



I am creating few reusable components via this which can be resused across my projects.. somehting like name component , phone number component etc..
I created the components..
but I am not sure how to include bootstrap in the library projects? The projects which consume my library will install bootstrap I guess...
How do i approach this?



This is not on how to add bootstrap to Angular application.. This is diffent and I am seeking opinion on how to add to Angular Library... Should I package it with my library or Should it be a peerdependency? If its a peer dependency , how do i go about it?



I have to use some mixins from bootstrap in the library project as well.. How to get them in the library project?










share|improve this question
















I am creating an angular library in an angular project using angular 6 library feature https://github.com/angular/angular-cli/wiki/stories-create-library



I am creating few reusable components via this which can be resused across my projects.. somehting like name component , phone number component etc..
I created the components..
but I am not sure how to include bootstrap in the library projects? The projects which consume my library will install bootstrap I guess...
How do i approach this?



This is not on how to add bootstrap to Angular application.. This is diffent and I am seeking opinion on how to add to Angular Library... Should I package it with my library or Should it be a peerdependency? If its a peer dependency , how do i go about it?



I have to use some mixins from bootstrap in the library project as well.. How to get them in the library project?







angular bootstrap-4






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 17 at 2:41







Jocket

















asked Jan 16 at 18:51









JocketJocket

7241735




7241735








  • 2





    Possible duplicate of How to use Bootstrap in an Angular project?

    – MassiveCodes
    Jan 16 at 19:03






  • 1





    Go for ng-bootstrap: you will have some convenient bootstrap components

    – Al-un
    Jan 16 at 19:03











  • This is particulary about Angular Library project..Not about Angular project...

    – Jocket
    Jan 16 at 19:04











  • is this what are you looking for?

    – Gaspar
    Jan 16 at 19:54













  • Not really..I am past this portion..its working..Now its more on specific problem about bootstrap and library

    – Jocket
    Jan 16 at 22:12














  • 2





    Possible duplicate of How to use Bootstrap in an Angular project?

    – MassiveCodes
    Jan 16 at 19:03






  • 1





    Go for ng-bootstrap: you will have some convenient bootstrap components

    – Al-un
    Jan 16 at 19:03











  • This is particulary about Angular Library project..Not about Angular project...

    – Jocket
    Jan 16 at 19:04











  • is this what are you looking for?

    – Gaspar
    Jan 16 at 19:54













  • Not really..I am past this portion..its working..Now its more on specific problem about bootstrap and library

    – Jocket
    Jan 16 at 22:12








2




2





Possible duplicate of How to use Bootstrap in an Angular project?

– MassiveCodes
Jan 16 at 19:03





Possible duplicate of How to use Bootstrap in an Angular project?

– MassiveCodes
Jan 16 at 19:03




1




1





Go for ng-bootstrap: you will have some convenient bootstrap components

– Al-un
Jan 16 at 19:03





Go for ng-bootstrap: you will have some convenient bootstrap components

– Al-un
Jan 16 at 19:03













This is particulary about Angular Library project..Not about Angular project...

– Jocket
Jan 16 at 19:04





This is particulary about Angular Library project..Not about Angular project...

– Jocket
Jan 16 at 19:04













is this what are you looking for?

– Gaspar
Jan 16 at 19:54







is this what are you looking for?

– Gaspar
Jan 16 at 19:54















Not really..I am past this portion..its working..Now its more on specific problem about bootstrap and library

– Jocket
Jan 16 at 22:12





Not really..I am past this portion..its working..Now its more on specific problem about bootstrap and library

– Jocket
Jan 16 at 22:12












4 Answers
4






active

oldest

votes


















1





+25









When you deliver your library you should add bootstrap as a peerDependency to package.json:



 "peerDependencies": {
"ngx-bootstrap": ">=<MIN-VERSION> <MAX-VERSION",
}


Due to peerDependencies when someone installs your library ngx-bootstrap will get installed automatically, if it's not present. When the wrong version is installed the user of your library gets a warning.



Here some more info: http://npm.github.io/using-pkgs-docs/package-json/types/peerdependencies.html






share|improve this answer
























  • How can i use bootstrap mixins and all?

    – Jocket
    Jan 23 at 22:10











  • What exactly do you mean? Using mixins inside your library or in a project which uses your library? As long as you have styles in your node_modules either from bootstrap or your lib you should be able to import it via tild e.g. @import ~my-lib/path/to/styles

    – J. S.
    Jan 25 at 7:35











  • within the library...

    – Jocket
    Jan 25 at 17:52











  • You can use the bootstrap mixins like in a normal project. Just import verything you need from your node_modules.

    – J. S.
    Jan 28 at 7:31



















0














1) you can directly install using



npm install bootstrap


and than in your angular cli you can inlude it using



"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
],


2) you can also use ngx-bootstrap, it will help you in many input components



npm install ngx-bootstrap





share|improve this answer
























  • my recommendation is to use NG-BOOTSTRAP instead of NGX-BOOTSTRAP, since NGX we should have jquery and angular is not responsible

    – JMF
    Jan 23 at 13:16











  • I am focussed on Angular Library .Not on angular application

    – Jocket
    Jan 23 at 22:10



















0














You can simply install normal bootstrap with the command below



npm i bootstrap


Then since you are using Angular 6, you will need an angular.json file anf the @angular-devkit/build-angular, not angular-cli.json. Install the devkit with the command below



npm i @angular-devkit/build-angular --save-dev


and add this line of code in the "architect" section under "build" and into "options" you need to place the style references. I have given an example below.



"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "public",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"preserveSymlinks": true,
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/bootstrap/dist/css/bootstrap-theme.min.css"],
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"assets": [
"src/favicon.ico",
"src/assets"
],
},
"local": {
"assets": [
"src/favicon.ico"
]
}
}
}


I recommend referring to the docs on the specifics around the devkit and the angular.json configuration






share|improve this answer
























  • is for Angular Library project? Or just Angular Project?

    – Jocket
    Jan 25 at 22:41



















0














I don't know if it answers your question, but firstly you have to add bootstrap to your library peer dependencies, after that, in all your projects which use that library you have to include bootstrap styles to global styles in angular.json.





After that you can use bootstrap classes from templates in your library and you can be sure that styles would be applied. Also, if you want to use mixins or variables from bootstrap, you can just import needed scss bootstrap files into your components' scss files in library, like that:



@import "~bootstrap/scss/bootstrap-grid";

@include media-breakpoint-up(sm) {
.some-class {
display: block;
}
}


During build all these imported scss files would be compiled and built into your library output files.





There are other ways to include styles to library, but all of them require interception/extension of library build process.






share|improve this answer
























  • what are the other ways?

    – Jocket
    Jan 26 at 16:45











  • The main problem, in my opinion, is that this way doesn't very descriptive in terms of requirement of bootstrap styles, so who would now that your library requires bootstrap to be included into global styles? You can do your own global style in library (some scss file) where you can import bootstrap and configure it there (in that file) specifically for your library, but you cannot just emit scss file from library so you need to add post build script that would do that, and your consumers should include your library's global styles file

    – Amir Arbabian
    Jan 26 at 17:32











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54223504%2fangular-6-library-using-bootstrap%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























4 Answers
4






active

oldest

votes








4 Answers
4






active

oldest

votes









active

oldest

votes






active

oldest

votes









1





+25









When you deliver your library you should add bootstrap as a peerDependency to package.json:



 "peerDependencies": {
"ngx-bootstrap": ">=<MIN-VERSION> <MAX-VERSION",
}


Due to peerDependencies when someone installs your library ngx-bootstrap will get installed automatically, if it's not present. When the wrong version is installed the user of your library gets a warning.



Here some more info: http://npm.github.io/using-pkgs-docs/package-json/types/peerdependencies.html






share|improve this answer
























  • How can i use bootstrap mixins and all?

    – Jocket
    Jan 23 at 22:10











  • What exactly do you mean? Using mixins inside your library or in a project which uses your library? As long as you have styles in your node_modules either from bootstrap or your lib you should be able to import it via tild e.g. @import ~my-lib/path/to/styles

    – J. S.
    Jan 25 at 7:35











  • within the library...

    – Jocket
    Jan 25 at 17:52











  • You can use the bootstrap mixins like in a normal project. Just import verything you need from your node_modules.

    – J. S.
    Jan 28 at 7:31
















1





+25









When you deliver your library you should add bootstrap as a peerDependency to package.json:



 "peerDependencies": {
"ngx-bootstrap": ">=<MIN-VERSION> <MAX-VERSION",
}


Due to peerDependencies when someone installs your library ngx-bootstrap will get installed automatically, if it's not present. When the wrong version is installed the user of your library gets a warning.



Here some more info: http://npm.github.io/using-pkgs-docs/package-json/types/peerdependencies.html






share|improve this answer
























  • How can i use bootstrap mixins and all?

    – Jocket
    Jan 23 at 22:10











  • What exactly do you mean? Using mixins inside your library or in a project which uses your library? As long as you have styles in your node_modules either from bootstrap or your lib you should be able to import it via tild e.g. @import ~my-lib/path/to/styles

    – J. S.
    Jan 25 at 7:35











  • within the library...

    – Jocket
    Jan 25 at 17:52











  • You can use the bootstrap mixins like in a normal project. Just import verything you need from your node_modules.

    – J. S.
    Jan 28 at 7:31














1





+25







1





+25



1




+25





When you deliver your library you should add bootstrap as a peerDependency to package.json:



 "peerDependencies": {
"ngx-bootstrap": ">=<MIN-VERSION> <MAX-VERSION",
}


Due to peerDependencies when someone installs your library ngx-bootstrap will get installed automatically, if it's not present. When the wrong version is installed the user of your library gets a warning.



Here some more info: http://npm.github.io/using-pkgs-docs/package-json/types/peerdependencies.html






share|improve this answer













When you deliver your library you should add bootstrap as a peerDependency to package.json:



 "peerDependencies": {
"ngx-bootstrap": ">=<MIN-VERSION> <MAX-VERSION",
}


Due to peerDependencies when someone installs your library ngx-bootstrap will get installed automatically, if it's not present. When the wrong version is installed the user of your library gets a warning.



Here some more info: http://npm.github.io/using-pkgs-docs/package-json/types/peerdependencies.html







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 23 at 8:23









J. S.J. S.

9531617




9531617













  • How can i use bootstrap mixins and all?

    – Jocket
    Jan 23 at 22:10











  • What exactly do you mean? Using mixins inside your library or in a project which uses your library? As long as you have styles in your node_modules either from bootstrap or your lib you should be able to import it via tild e.g. @import ~my-lib/path/to/styles

    – J. S.
    Jan 25 at 7:35











  • within the library...

    – Jocket
    Jan 25 at 17:52











  • You can use the bootstrap mixins like in a normal project. Just import verything you need from your node_modules.

    – J. S.
    Jan 28 at 7:31



















  • How can i use bootstrap mixins and all?

    – Jocket
    Jan 23 at 22:10











  • What exactly do you mean? Using mixins inside your library or in a project which uses your library? As long as you have styles in your node_modules either from bootstrap or your lib you should be able to import it via tild e.g. @import ~my-lib/path/to/styles

    – J. S.
    Jan 25 at 7:35











  • within the library...

    – Jocket
    Jan 25 at 17:52











  • You can use the bootstrap mixins like in a normal project. Just import verything you need from your node_modules.

    – J. S.
    Jan 28 at 7:31

















How can i use bootstrap mixins and all?

– Jocket
Jan 23 at 22:10





How can i use bootstrap mixins and all?

– Jocket
Jan 23 at 22:10













What exactly do you mean? Using mixins inside your library or in a project which uses your library? As long as you have styles in your node_modules either from bootstrap or your lib you should be able to import it via tild e.g. @import ~my-lib/path/to/styles

– J. S.
Jan 25 at 7:35





What exactly do you mean? Using mixins inside your library or in a project which uses your library? As long as you have styles in your node_modules either from bootstrap or your lib you should be able to import it via tild e.g. @import ~my-lib/path/to/styles

– J. S.
Jan 25 at 7:35













within the library...

– Jocket
Jan 25 at 17:52





within the library...

– Jocket
Jan 25 at 17:52













You can use the bootstrap mixins like in a normal project. Just import verything you need from your node_modules.

– J. S.
Jan 28 at 7:31





You can use the bootstrap mixins like in a normal project. Just import verything you need from your node_modules.

– J. S.
Jan 28 at 7:31













0














1) you can directly install using



npm install bootstrap


and than in your angular cli you can inlude it using



"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
],


2) you can also use ngx-bootstrap, it will help you in many input components



npm install ngx-bootstrap





share|improve this answer
























  • my recommendation is to use NG-BOOTSTRAP instead of NGX-BOOTSTRAP, since NGX we should have jquery and angular is not responsible

    – JMF
    Jan 23 at 13:16











  • I am focussed on Angular Library .Not on angular application

    – Jocket
    Jan 23 at 22:10
















0














1) you can directly install using



npm install bootstrap


and than in your angular cli you can inlude it using



"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
],


2) you can also use ngx-bootstrap, it will help you in many input components



npm install ngx-bootstrap





share|improve this answer
























  • my recommendation is to use NG-BOOTSTRAP instead of NGX-BOOTSTRAP, since NGX we should have jquery and angular is not responsible

    – JMF
    Jan 23 at 13:16











  • I am focussed on Angular Library .Not on angular application

    – Jocket
    Jan 23 at 22:10














0












0








0







1) you can directly install using



npm install bootstrap


and than in your angular cli you can inlude it using



"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
],


2) you can also use ngx-bootstrap, it will help you in many input components



npm install ngx-bootstrap





share|improve this answer













1) you can directly install using



npm install bootstrap


and than in your angular cli you can inlude it using



"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
],


2) you can also use ngx-bootstrap, it will help you in many input components



npm install ngx-bootstrap






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 23 at 7:15









edrich13edrich13

104110




104110













  • my recommendation is to use NG-BOOTSTRAP instead of NGX-BOOTSTRAP, since NGX we should have jquery and angular is not responsible

    – JMF
    Jan 23 at 13:16











  • I am focussed on Angular Library .Not on angular application

    – Jocket
    Jan 23 at 22:10



















  • my recommendation is to use NG-BOOTSTRAP instead of NGX-BOOTSTRAP, since NGX we should have jquery and angular is not responsible

    – JMF
    Jan 23 at 13:16











  • I am focussed on Angular Library .Not on angular application

    – Jocket
    Jan 23 at 22:10

















my recommendation is to use NG-BOOTSTRAP instead of NGX-BOOTSTRAP, since NGX we should have jquery and angular is not responsible

– JMF
Jan 23 at 13:16





my recommendation is to use NG-BOOTSTRAP instead of NGX-BOOTSTRAP, since NGX we should have jquery and angular is not responsible

– JMF
Jan 23 at 13:16













I am focussed on Angular Library .Not on angular application

– Jocket
Jan 23 at 22:10





I am focussed on Angular Library .Not on angular application

– Jocket
Jan 23 at 22:10











0














You can simply install normal bootstrap with the command below



npm i bootstrap


Then since you are using Angular 6, you will need an angular.json file anf the @angular-devkit/build-angular, not angular-cli.json. Install the devkit with the command below



npm i @angular-devkit/build-angular --save-dev


and add this line of code in the "architect" section under "build" and into "options" you need to place the style references. I have given an example below.



"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "public",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"preserveSymlinks": true,
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/bootstrap/dist/css/bootstrap-theme.min.css"],
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"assets": [
"src/favicon.ico",
"src/assets"
],
},
"local": {
"assets": [
"src/favicon.ico"
]
}
}
}


I recommend referring to the docs on the specifics around the devkit and the angular.json configuration






share|improve this answer
























  • is for Angular Library project? Or just Angular Project?

    – Jocket
    Jan 25 at 22:41
















0














You can simply install normal bootstrap with the command below



npm i bootstrap


Then since you are using Angular 6, you will need an angular.json file anf the @angular-devkit/build-angular, not angular-cli.json. Install the devkit with the command below



npm i @angular-devkit/build-angular --save-dev


and add this line of code in the "architect" section under "build" and into "options" you need to place the style references. I have given an example below.



"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "public",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"preserveSymlinks": true,
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/bootstrap/dist/css/bootstrap-theme.min.css"],
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"assets": [
"src/favicon.ico",
"src/assets"
],
},
"local": {
"assets": [
"src/favicon.ico"
]
}
}
}


I recommend referring to the docs on the specifics around the devkit and the angular.json configuration






share|improve this answer
























  • is for Angular Library project? Or just Angular Project?

    – Jocket
    Jan 25 at 22:41














0












0








0







You can simply install normal bootstrap with the command below



npm i bootstrap


Then since you are using Angular 6, you will need an angular.json file anf the @angular-devkit/build-angular, not angular-cli.json. Install the devkit with the command below



npm i @angular-devkit/build-angular --save-dev


and add this line of code in the "architect" section under "build" and into "options" you need to place the style references. I have given an example below.



"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "public",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"preserveSymlinks": true,
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/bootstrap/dist/css/bootstrap-theme.min.css"],
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"assets": [
"src/favicon.ico",
"src/assets"
],
},
"local": {
"assets": [
"src/favicon.ico"
]
}
}
}


I recommend referring to the docs on the specifics around the devkit and the angular.json configuration






share|improve this answer













You can simply install normal bootstrap with the command below



npm i bootstrap


Then since you are using Angular 6, you will need an angular.json file anf the @angular-devkit/build-angular, not angular-cli.json. Install the devkit with the command below



npm i @angular-devkit/build-angular --save-dev


and add this line of code in the "architect" section under "build" and into "options" you need to place the style references. I have given an example below.



"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "public",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"preserveSymlinks": true,
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/bootstrap/dist/css/bootstrap-theme.min.css"],
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"assets": [
"src/favicon.ico",
"src/assets"
],
},
"local": {
"assets": [
"src/favicon.ico"
]
}
}
}


I recommend referring to the docs on the specifics around the devkit and the angular.json configuration







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 25 at 21:41









Ben BrownBen Brown

1427




1427













  • is for Angular Library project? Or just Angular Project?

    – Jocket
    Jan 25 at 22:41



















  • is for Angular Library project? Or just Angular Project?

    – Jocket
    Jan 25 at 22:41

















is for Angular Library project? Or just Angular Project?

– Jocket
Jan 25 at 22:41





is for Angular Library project? Or just Angular Project?

– Jocket
Jan 25 at 22:41











0














I don't know if it answers your question, but firstly you have to add bootstrap to your library peer dependencies, after that, in all your projects which use that library you have to include bootstrap styles to global styles in angular.json.





After that you can use bootstrap classes from templates in your library and you can be sure that styles would be applied. Also, if you want to use mixins or variables from bootstrap, you can just import needed scss bootstrap files into your components' scss files in library, like that:



@import "~bootstrap/scss/bootstrap-grid";

@include media-breakpoint-up(sm) {
.some-class {
display: block;
}
}


During build all these imported scss files would be compiled and built into your library output files.





There are other ways to include styles to library, but all of them require interception/extension of library build process.






share|improve this answer
























  • what are the other ways?

    – Jocket
    Jan 26 at 16:45











  • The main problem, in my opinion, is that this way doesn't very descriptive in terms of requirement of bootstrap styles, so who would now that your library requires bootstrap to be included into global styles? You can do your own global style in library (some scss file) where you can import bootstrap and configure it there (in that file) specifically for your library, but you cannot just emit scss file from library so you need to add post build script that would do that, and your consumers should include your library's global styles file

    – Amir Arbabian
    Jan 26 at 17:32
















0














I don't know if it answers your question, but firstly you have to add bootstrap to your library peer dependencies, after that, in all your projects which use that library you have to include bootstrap styles to global styles in angular.json.





After that you can use bootstrap classes from templates in your library and you can be sure that styles would be applied. Also, if you want to use mixins or variables from bootstrap, you can just import needed scss bootstrap files into your components' scss files in library, like that:



@import "~bootstrap/scss/bootstrap-grid";

@include media-breakpoint-up(sm) {
.some-class {
display: block;
}
}


During build all these imported scss files would be compiled and built into your library output files.





There are other ways to include styles to library, but all of them require interception/extension of library build process.






share|improve this answer
























  • what are the other ways?

    – Jocket
    Jan 26 at 16:45











  • The main problem, in my opinion, is that this way doesn't very descriptive in terms of requirement of bootstrap styles, so who would now that your library requires bootstrap to be included into global styles? You can do your own global style in library (some scss file) where you can import bootstrap and configure it there (in that file) specifically for your library, but you cannot just emit scss file from library so you need to add post build script that would do that, and your consumers should include your library's global styles file

    – Amir Arbabian
    Jan 26 at 17:32














0












0








0







I don't know if it answers your question, but firstly you have to add bootstrap to your library peer dependencies, after that, in all your projects which use that library you have to include bootstrap styles to global styles in angular.json.





After that you can use bootstrap classes from templates in your library and you can be sure that styles would be applied. Also, if you want to use mixins or variables from bootstrap, you can just import needed scss bootstrap files into your components' scss files in library, like that:



@import "~bootstrap/scss/bootstrap-grid";

@include media-breakpoint-up(sm) {
.some-class {
display: block;
}
}


During build all these imported scss files would be compiled and built into your library output files.





There are other ways to include styles to library, but all of them require interception/extension of library build process.






share|improve this answer













I don't know if it answers your question, but firstly you have to add bootstrap to your library peer dependencies, after that, in all your projects which use that library you have to include bootstrap styles to global styles in angular.json.





After that you can use bootstrap classes from templates in your library and you can be sure that styles would be applied. Also, if you want to use mixins or variables from bootstrap, you can just import needed scss bootstrap files into your components' scss files in library, like that:



@import "~bootstrap/scss/bootstrap-grid";

@include media-breakpoint-up(sm) {
.some-class {
display: block;
}
}


During build all these imported scss files would be compiled and built into your library output files.





There are other ways to include styles to library, but all of them require interception/extension of library build process.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 26 at 15:30









Amir ArbabianAmir Arbabian

80214




80214













  • what are the other ways?

    – Jocket
    Jan 26 at 16:45











  • The main problem, in my opinion, is that this way doesn't very descriptive in terms of requirement of bootstrap styles, so who would now that your library requires bootstrap to be included into global styles? You can do your own global style in library (some scss file) where you can import bootstrap and configure it there (in that file) specifically for your library, but you cannot just emit scss file from library so you need to add post build script that would do that, and your consumers should include your library's global styles file

    – Amir Arbabian
    Jan 26 at 17:32



















  • what are the other ways?

    – Jocket
    Jan 26 at 16:45











  • The main problem, in my opinion, is that this way doesn't very descriptive in terms of requirement of bootstrap styles, so who would now that your library requires bootstrap to be included into global styles? You can do your own global style in library (some scss file) where you can import bootstrap and configure it there (in that file) specifically for your library, but you cannot just emit scss file from library so you need to add post build script that would do that, and your consumers should include your library's global styles file

    – Amir Arbabian
    Jan 26 at 17:32

















what are the other ways?

– Jocket
Jan 26 at 16:45





what are the other ways?

– Jocket
Jan 26 at 16:45













The main problem, in my opinion, is that this way doesn't very descriptive in terms of requirement of bootstrap styles, so who would now that your library requires bootstrap to be included into global styles? You can do your own global style in library (some scss file) where you can import bootstrap and configure it there (in that file) specifically for your library, but you cannot just emit scss file from library so you need to add post build script that would do that, and your consumers should include your library's global styles file

– Amir Arbabian
Jan 26 at 17:32





The main problem, in my opinion, is that this way doesn't very descriptive in terms of requirement of bootstrap styles, so who would now that your library requires bootstrap to be included into global styles? You can do your own global style in library (some scss file) where you can import bootstrap and configure it there (in that file) specifically for your library, but you cannot just emit scss file from library so you need to add post build script that would do that, and your consumers should include your library's global styles file

– Amir Arbabian
Jan 26 at 17:32


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54223504%2fangular-6-library-using-bootstrap%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Callistus III

Ostreoida

Plistias Cous