forked from bline/bootstrap-webpack
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added flexibility to customise loaders
- Loading branch information
Gowrav Shekar
authored and
Gowrav Shekar
committed
Oct 2, 2015
1 parent
2f74ae8
commit 31b3f2f
Showing
4 changed files
with
52 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,29 @@ | ||
module.exports = function () {}; | ||
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); | ||
var config = require(this.resourcePath); | ||
var postStyleLoaders = ''; | ||
if((typeof config.postStyleLoaders !== 'undefined') && (config.postStyleLoaders.length > 0)){ | ||
postStyleLoaders = config.postStyleLoaders.join('!') + '!'; | ||
|
||
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); | ||
} | ||
return [ | ||
'require(' + JSON.stringify("-!" + postStyleLoaders + require.resolve("style-loader") + '!' + require.resolve("css-loader") + | ||
'!' + require.resolve("less-loader") + '!' + require.resolve("./bootstrap-styles.loader.js") + '!' + remainingRequest) + ');', | ||
'require(' + JSON.stringify("-!" + require.resolve("./bootstrap-scripts.loader.js") + "!" + remainingRequest) + ');' | ||
].join("\n"); | ||
|
||
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; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters