forked from vitalyrotari/foundation-sites-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.loader.js
37 lines (31 loc) · 1.34 KB
/
index.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
var logger = require('./logger');
module.exports = function() {
};
module.exports.pitch = function(remainingRequest) {
var result;
var jsLoaderCommand;
var styleLoaderCommand;
var styleLoader;
var config;
var msg;
// Webpack 1.7.3 uses this.resourcePath. Leaving in remaining request for possibly older versions
// of Webpack
var configFilePath = this.resourcePath || remainingRequest;
this.cacheable(true);
if (!configFilePath || configFilePath.trim() === '') {
msg = 'You specified the foundation-sites-loader with no configuration file. Please specify' +
' the configuration file, like: \'foundation-sites!./foundation-sites.config.js\' or use' +
' require(\'foundation-sites-loader\').';
console.error('ERROR: ' + msg);
throw new Error(msg);
}
config = require(configFilePath);
styleLoader = config.styleLoader || 'style-loader!css-loader!sass-loader';
logger.verbose(config, 'styleLoader: %s', styleLoader);
styleLoaderCommand = 'require(' + JSON.stringify('-!' + styleLoader + '!' +
require.resolve('./foundation-sites-styles.loader.js') + '!' + configFilePath) + ');';
jsLoaderCommand = 'require(' + JSON.stringify('-!' +
require.resolve('./foundation-sites-scripts.loader.js') + '!' + configFilePath) + ');';
result = [styleLoaderCommand, jsLoaderCommand].join('\n');
return result;
};