This repository was archived by the owner on Mar 17, 2018. It is now read-only.
forked from shakacode/bootstrap-sass-loader
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap-styles.loader.js
More file actions
99 lines (84 loc) · 2.29 KB
/
bootstrap-styles.loader.js
File metadata and controls
99 lines (84 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
var partials = [
'mixins',
'normalize',
'print',
'reboot',
'type',
'images',
'code',
'grid',
'tables',
'forms',
'buttons',
'animation',
'dropdown',
'button-group',
'input-group',
'custom-forms',
'nav',
'navbar',
'card',
'breadcrumb',
'pagination',
'pager',
'labels',
'jumbotron',
'alert',
'progress',
'media',
'list-group',
'responsive-embed',
'close',
'modal',
'tooltip',
'popover',
'carousel',
'utilities',
'utilities-background',
'utilities-spacing',
'utilities-responsive'
];
var path = require('path');
var bootstrapPath = require('./bootstrapPath');
var logger = require('./logger');
function addImportReturnDependency(loader, config, propertyName) {
var fileNameResolved;
var fileName = config[propertyName];
if (fileName && fileName.length > 0) {
fileNameResolved = path.relative(loader.context, fileName);
logger.verbose(config, 'fileName for %s: %s', propertyName, fileNameResolved);
loader.addDependency(fileNameResolved);
return '@import \'' + fileNameResolved + '\';\n';
}
}
module.exports = function(content) {
var source;
var config = this.exec(content, this.resourcePath);
var pathToBootstrap = bootstrapPath.getPath(this.context);
var relativePathToBootstrap = path.relative(this.context, pathToBootstrap);
var start = '';
this.cacheable(true);
logger.verbose(config, 'bootstrap location: %s', relativePathToBootstrap);
if (config.preBootstrapCustomizations) {
start += addImportReturnDependency(this, config, 'preBootstrapCustomizations');
}
start +=
// Absolute paths as these are created at build time.
'@import \'' + path.join(relativePathToBootstrap,
'scss/variables') + '\';\n';
if (config.bootstrapCustomizations) {
start += addImportReturnDependency(this, config, 'bootstrapCustomizations');
}
source = start + partials.filter(function(partial) {
return config.styles[partial];
}).map(function(partial) {
return '@import \'' + path.join(relativePathToBootstrap, 'scss',
partial) + '\';';
}).join('\n');
if (config.mainSass) {
source += '\n' + addImportReturnDependency(this, config, 'mainSass');
}
source = source.replace(/\\/g, '/');
logger.debug(config, 'Generated scss file is:\n' + source);
return source;
};