forked from bline/bootstrap-webpack
-
Notifications
You must be signed in to change notification settings - Fork 22
/
index.loader.js
29 lines (23 loc) · 1.14 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
module.exports = function() {
};
module.exports.pitch = function (remainingRequest) {
// 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() === '') {
var msg = 'You specified the bootstrap-webpack with no configuration file. Please specify' +
' the configuration file, like: \'bootstrap-webpack!./bootstrap.config.js\' or use' +
' require(\'bootstrap-webpack\').';
console.error('ERROR: ' + msg);
throw new Error(msg);
}
var config = require(configFilePath);
var styleLoader = config.styleLoader || 'style-loader!css-loader!less-loader';
var styleLoaderCommand = 'require(' + JSON.stringify('-!' + styleLoader + '!' +
require.resolve('./bootstrap-styles.loader.js') + '!' + configFilePath) + ');';
var jsLoaderCommand = 'require(' + JSON.stringify('-!' +
require.resolve('./bootstrap-scripts.loader.js') + '!' + configFilePath) + ');';
var result = [styleLoaderCommand, jsLoaderCommand].join('\n');
return result;
};