Skip to content

Commit 66f405e

Browse files
committed
Merge pull request #39 from HorizonXP/allow-custom-icon-font-path
Add option for custom $icon-font-path
2 parents 33a9529 + 2662d59 commit 66f405e

File tree

10 files changed

+45
-1
lines changed

10 files changed

+45
-1
lines changed

.bootstraprc-3-default

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# Major version of Bootstrap: 3 or 4
66
bootstrapVersion: 3
77

8+
# If Bootstrap version 3 is used - turn on/off custom icon font path
9+
useCustomIconFontPath: false
10+
811
# Webpack loaders, order matters
912
styleLoaders:
1013
- style

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,22 @@ scripts:
218218
scripts: true / false
219219
```
220220

221+
#### `useCustomIconFontPath`
222+
223+
Default: false
224+
225+
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.
226+
227+
```yaml
228+
useCustomIconFontPath: true / false
229+
```
230+
231+
```
232+
$icon-font-path: ../fonts // relative to your Sass file
233+
$icon-font-name: 'glyphicons' // you'll typically want to change this too.
234+
```
235+
236+
221237
### Bootstrap 4
222238
There is only one additional option for Bootstrap 4:
223239

examples/basic/.bootstraprc

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# Major version of Bootstrap: 3 or 4
66
bootstrapVersion: 3
77

8+
# If Bootstrap version 3 is used - turn on/off custom icon font path
9+
useCustomIconFontPath: false
10+
811
# Webpack loaders, order matters
912
styleLoaders:
1013
- style

examples/basic/.bootstraprc-3-example

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# Major version of Bootstrap: 3 or 4
66
bootstrapVersion: 3
77

8+
# If Bootstrap version 3 is used - turn on/off custom icon font path
9+
useCustomIconFontPath: false
10+
811
# Webpack loaders, order matters
912
styleLoaders:
1013
- style

examples/basic/app/styles/bootstrap/pre-customizations.scss

+5
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@ $fonts-url-path: '../fonts';
1919
// $font-size-base: 14px !default;
2020
// $font-size-large: ceil(($font-size-base * 1.25)) !default; // ~18px
2121
// $font-size-small: ceil(($font-size-base * 0.85)) !default; // ~12px
22+
23+
// If you're using a custom icon font path, specify it as follows
24+
// $icon-font-path: ../fonts // This path is relative to this file
25+
// $icon-font-name: 'glyphicons' // The name of the font you want to use
26+
// And be sure to set useCustomIconFontPath to true in .bootstraprc.

examples/css-modules/.bootstraprc

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# Major version of Bootstrap: 3 or 4
66
bootstrapVersion: 3
77

8+
# If Bootstrap version 3 is used - turn on/off custom icon font path
9+
useCustomIconFontPath: false
10+
811
# Webpack loaders, order matters
912
styleLoaders:
1013
- style

examples/css-modules/.bootstraprc-3-example

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# Major version of Bootstrap: 3 or 4
66
bootstrapVersion: 3
77

8+
# If Bootstrap version 3 is used - turn on/off custom icon font path
9+
useCustomIconFontPath: false
10+
811
# Webpack loaders, order matters
912
styleLoaders:
1013
- style

examples/css-modules/app/assets/styles/bootstrap/pre-customizations.scss

+5
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ $fonts-url-path: '../../fonts';
1212
src: url('#{$fonts-url-path}/OpenSans-Light.ttf') format('truetype');
1313

1414
}
15+
16+
// If you're using a custom icon font path, specify it as follows
17+
// $icon-font-path: ../fonts // This path is relative to this file
18+
// $icon-font-name: 'glyphicons' // The name of the font you want to use
19+
// And be sure to set useCustomIconFontPath to true in .bootstraprc.

src/bootstrap.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export function createConfig({
8686
bootstrapCustomizations,
8787
appStyles,
8888
useFlexbox: rawConfig.useFlexbox,
89+
useCustomIconFontPath: rawConfig.useCustomIconFontPath,
8990
extractStyles: extractStyles || getEnvProp('extractStyles', rawConfig),
9091
styleLoaders: rawConfig.styleLoaders,
9192
styles: selectUserModules(rawConfig.styles, defaultConfig.styles),
@@ -99,6 +100,7 @@ export function createConfig({
99100
bootstrapVersion,
100101
loglevel,
101102
useFlexbox: defaultConfig.useFlexbox,
103+
useCustomIconFontPath: defaultConfig.useCustomIconFontPath,
102104
extractStyles: extractStyles || getEnvProp('extractStyles', defaultConfig),
103105
styleLoaders: defaultConfig.styleLoaders,
104106
styles: selectModules(defaultConfig.styles),

src/bootstrap.styles.loader.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module.exports = function() {
2020
styles,
2121
bootstrapRelPath,
2222
useFlexbox,
23+
useCustomIconFontPath,
2324
preBootstrapCustomizations,
2425
bootstrapCustomizations,
2526
appStyles,
@@ -47,7 +48,7 @@ module.exports = function() {
4748
createBootstrapImport('variables', bootstrapVersion, bootstrapRelPath)
4849
);
4950

50-
if (bootstrapVersion === 3) {
51+
if (bootstrapVersion === 3 && !useCustomIconFontPath) {
5152
processedStyles.push(
5253
`$icon-font-path: "${getFontsPath(bootstrapRelPath, this)}";`
5354
);

0 commit comments

Comments
 (0)