Skip to content

Commit

Permalink
Merge pull request #39 from HorizonXP/allow-custom-icon-font-path
Browse files Browse the repository at this point in the history
Add option for custom $icon-font-path
  • Loading branch information
alex35mil committed Feb 8, 2016
2 parents 33a9529 + 2662d59 commit 66f405e
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .bootstraprc-3-default
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# Major version of Bootstrap: 3 or 4
bootstrapVersion: 3

# If Bootstrap version 3 is used - turn on/off custom icon font path
useCustomIconFontPath: false

# Webpack loaders, order matters
styleLoaders:
- style
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,22 @@ scripts:
scripts: true / false
```

#### `useCustomIconFontPath`

Default: false

If you're using a custom icon font and you need to specify its path (`$icon-font-path`) in your Sass files, set this option to true.

```yaml
useCustomIconFontPath: true / false
```

```
$icon-font-path: ../fonts // relative to your Sass file
$icon-font-name: 'glyphicons' // you'll typically want to change this too.
```
### Bootstrap 4
There is only one additional option for Bootstrap 4:
Expand Down
3 changes: 3 additions & 0 deletions examples/basic/.bootstraprc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# Major version of Bootstrap: 3 or 4
bootstrapVersion: 3

# If Bootstrap version 3 is used - turn on/off custom icon font path
useCustomIconFontPath: false

# Webpack loaders, order matters
styleLoaders:
- style
Expand Down
3 changes: 3 additions & 0 deletions examples/basic/.bootstraprc-3-example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# Major version of Bootstrap: 3 or 4
bootstrapVersion: 3

# If Bootstrap version 3 is used - turn on/off custom icon font path
useCustomIconFontPath: false

# Webpack loaders, order matters
styleLoaders:
- style
Expand Down
5 changes: 5 additions & 0 deletions examples/basic/app/styles/bootstrap/pre-customizations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ $fonts-url-path: '../fonts';
// $font-size-base: 14px !default;
// $font-size-large: ceil(($font-size-base * 1.25)) !default; // ~18px
// $font-size-small: ceil(($font-size-base * 0.85)) !default; // ~12px

// If you're using a custom icon font path, specify it as follows
// $icon-font-path: ../fonts // This path is relative to this file
// $icon-font-name: 'glyphicons' // The name of the font you want to use
// And be sure to set useCustomIconFontPath to true in .bootstraprc.
3 changes: 3 additions & 0 deletions examples/css-modules/.bootstraprc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# Major version of Bootstrap: 3 or 4
bootstrapVersion: 3

# If Bootstrap version 3 is used - turn on/off custom icon font path
useCustomIconFontPath: false

# Webpack loaders, order matters
styleLoaders:
- style
Expand Down
3 changes: 3 additions & 0 deletions examples/css-modules/.bootstraprc-3-example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# Major version of Bootstrap: 3 or 4
bootstrapVersion: 3

# If Bootstrap version 3 is used - turn on/off custom icon font path
useCustomIconFontPath: false

# Webpack loaders, order matters
styleLoaders:
- style
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ $fonts-url-path: '../../fonts';
src: url('#{$fonts-url-path}/OpenSans-Light.ttf') format('truetype');

}

// If you're using a custom icon font path, specify it as follows
// $icon-font-path: ../fonts // This path is relative to this file
// $icon-font-name: 'glyphicons' // The name of the font you want to use
// And be sure to set useCustomIconFontPath to true in .bootstraprc.
2 changes: 2 additions & 0 deletions src/bootstrap.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export function createConfig({
bootstrapCustomizations,
appStyles,
useFlexbox: rawConfig.useFlexbox,
useCustomIconFontPath: rawConfig.useCustomIconFontPath,
extractStyles: extractStyles || getEnvProp('extractStyles', rawConfig),
styleLoaders: rawConfig.styleLoaders,
styles: selectUserModules(rawConfig.styles, defaultConfig.styles),
Expand All @@ -99,6 +100,7 @@ export function createConfig({
bootstrapVersion,
loglevel,
useFlexbox: defaultConfig.useFlexbox,
useCustomIconFontPath: defaultConfig.useCustomIconFontPath,
extractStyles: extractStyles || getEnvProp('extractStyles', defaultConfig),
styleLoaders: defaultConfig.styleLoaders,
styles: selectModules(defaultConfig.styles),
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap.styles.loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = function() {
styles,
bootstrapRelPath,
useFlexbox,
useCustomIconFontPath,
preBootstrapCustomizations,
bootstrapCustomizations,
appStyles,
Expand Down Expand Up @@ -47,7 +48,7 @@ module.exports = function() {
createBootstrapImport('variables', bootstrapVersion, bootstrapRelPath)
);

if (bootstrapVersion === 3) {
if (bootstrapVersion === 3 && !useCustomIconFontPath) {
processedStyles.push(
`$icon-font-path: "${getFontsPath(bootstrapRelPath, this)}";`
);
Expand Down

0 comments on commit 66f405e

Please sign in to comment.