-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfoundation-sites-styles.loader.js
90 lines (79 loc) · 2.71 KB
/
foundation-sites-styles.loader.js
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
var partials = [
'grid/grid',
'typography/typography',
'forms/forms',
'components/visibility',
'components/float',
'components/button',
'components/button-group',
'components/accordion-menu',
'components/accordion',
'components/badge',
'components/breadcrumbs',
'components/callout',
'components/close-button',
'components/drilldown',
'components/dropdown-menu',
'components/dropdown',
'components/flex-video',
'components/label',
'components/media-object',
'components/menu',
'components/off-canvas',
'components/orbit',
'components/pagination',
'components/progress-bar',
'components/reveal',
'components/slider',
'components/sticky',
'components/switch',
'components/table',
'components/tabs',
'components/title-bar',
'components/top-bar',
'components/thumbnail',
'components/tooltip'
];
var path = require('path');
var foundationSitesPath = require('./foundationSitesPath');
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 pathToBootstrapSass = foundationSitesPath.getPath(this.context);
var relativePathToFoundationSites = path.relative(this.context, pathToBootstrapSass);
var start = '';
this.cacheable(true);
logger.verbose(config, 'foundation-sites location: %s', relativePathToFoundationSites);
if (config.preFoundationCustomizations) {
start += addImportReturnDependency(this, config, 'preFoundationCustomizations');
}
start +=
// Absolute paths as these are created at build time.
'@import \'' + path.join(relativePathToFoundationSites, 'scss/util/util') + '\';\n' +
'@import \'' + path.join(relativePathToFoundationSites, 'scss/global') + '\';\n';
if (config.foundationCustomizations) {
start += addImportReturnDependency(this, config, 'foundationCustomizations');
}
source = start + partials.filter(function(partial) {
return config.styles[partial];
}).map(function(partial) {
return '@import \'' + path.join(relativePathToFoundationSites, '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;
};