Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Bootstrap 4 #38

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
**Important:** This is still the readme of [shakacode/bootstrap-sass-loader](https://github.com/shakacode/bootstrap-sass-loader), the Bootstrap 3 (!) Sass package. Since this package for Bootstrap 4 is based on bootstrap-sass-loader most of the readme should be up to date nonetheless.

Make sure to load a version of Bootstrap 4 (e. g. `"bootstrap": "twbs/bootstrap#v4-dev"`) instead of Bootstrap 3 Sass (`"bootstrap-sass": "~3.3.1"`).

bootstrap-sass-loader
=================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,61 @@ module.exports = {
styleLoader: 'style-loader!css-loader!sass-loader',

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about if we simply have a property:

 bootstrapVersion: 3,

or

 bootstrapVersion: 4,

scripts: {
'transition': true,
'util': true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need different manifest files for Bootstrap 3 and Bootstrap 4

'alert': true,
'button': true,
'carousel': true,
'collapse': true,
'dropdown': true,
'modal': true,
'tooltip': true,
'popover': true,
'scrollspy': true,
'tab': true,
'affix': true
'tooltip': true,
'popover': true
},
styles: {
'mixins': true,

'normalize': true,
'print': true,
'glyphicons': true,

'scaffolding': true,
'reboot': true,
'type': true,
'images': true,
'code': true,
'grid': true,
'tables': true,
'forms': true,
'buttons': true,

'component-animations': true,
'dropdowns': true,
'button-groups': true,
'input-groups': true,
'navs': true,
'animation': true,
'dropdown': true,
'button-group': true,
'input-group': true,
'custom-forms': true,
'nav': true,
'navbar': true,
'breadcrumbs': true,
'card': true,
'breadcrumb': true,
'pagination': true,
'pager': true,
'labels': true,
'badges': true,
'jumbotron': true,
'thumbnails': true,
'alerts': true,
'progress-bars': true,
'alert': true,
'progress': true,
'media': true,
'list-group': true,
'panels': true,
'wells': true,
'responsive-embed': true,
'close': true,

'modals': true,
'modal': true,
'tooltip': true,
'popovers': true,
'popover': true,
'carousel': true,

'utilities': true,
'responsive-utilities': true
'utilities-background': true,
'utilities-spacing': true,
'utilities-responsive': true
}
};
13 changes: 6 additions & 7 deletions bootstrap-sass-scripts.loader.js → bootstrap-scripts.loader.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
var scripts = [
'transition',
'util',
'alert',
'button',
'carousel',
'collapse',
'dropdown',
'modal',
'tooltip',
'popover',
'scrollspy',
'tab',
'affix'
'tooltip',
'popover'
];

var bootstrapSassPath = require('./bootstrapSassPath');
var bootstrapPath = require('./bootstrapPath');
var path = require('path');

module.exports = function() {
Expand All @@ -22,13 +21,13 @@ module.exports = function() {

// Create a list of require('path/to/bootstrap.js');
module.exports.pitch = function(configPath) {
var pathToBootstrapSass = bootstrapSassPath.getPath(this.context);
var pathToBootstrap = bootstrapPath.getPath(this.context);
var config = require(configPath);
this.cacheable(true);
return scripts.filter(function(script) {
return config.scripts[script];
}).map(function(script) {
var pathToBootstrapJsFile = JSON.stringify(path.join(pathToBootstrapSass, 'javascripts',
var pathToBootstrapJsFile = JSON.stringify(path.join(pathToBootstrap, 'js/src',
'bootstrap', script));
return 'require(' + pathToBootstrapJsFile + ');';
}).join('\n');
Expand Down
51 changes: 24 additions & 27 deletions bootstrap-sass-styles.loader.js → bootstrap-styles.loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,48 @@ var partials = [

'normalize',
'print',
'glyphicons',

'scaffolding',
'reboot',
'type',
'images',
'code',
'grid',
'tables',
'forms',
'buttons',

'component-animations',
'dropdowns',
'button-groups',
'input-groups',
'navs',
'animation',
'dropdown',
'button-group',
'input-group',
'custom-forms',
'nav',
'navbar',
'breadcrumbs',
'card',
'breadcrumb',
'pagination',
'pager',
'labels',
'badges',
'jumbotron',
'thumbnails',
'alerts',
'progress-bars',
'alert',
'progress',
'media',
'list-group',
'panels',
'wells',
'responsive-embed',
'close',

'modals',
'modal',
'tooltip',
'popovers',
'popover',
'carousel',

'utilities',
'responsive-utilities'
'utilities-background',
'utilities-spacing',
'utilities-responsive'
];
var path = require('path');
var bootstrapSassPath = require('./bootstrapSassPath');
var bootstrapPath = require('./bootstrapPath');
var logger = require('./logger');

function addImportReturnDependency(loader, config, propertyName) {
Expand All @@ -62,22 +62,19 @@ function addImportReturnDependency(loader, config, propertyName) {
module.exports = function(content) {
var source;
var config = this.exec(content, this.resourcePath);
var pathToBootstrapSass = bootstrapSassPath.getPath(this.context);
var relativePathToBootstrapSass = path.relative(this.context, pathToBootstrapSass);
var pathToBootstrap = bootstrapPath.getPath(this.context);
var relativePathToBootstrap = path.relative(this.context, pathToBootstrap);
var start = '';
// This needs to be relative
var iconFontPath = '$icon-font-path: \'' + path.join(relativePathToBootstrapSass, 'fonts/bootstrap/') + '\';';
this.cacheable(true);
logger.verbose(config, 'bootstrap-sass location: %s', relativePathToBootstrapSass);
logger.verbose(config, 'Setting: %s', iconFontPath);
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(relativePathToBootstrapSass,
'stylesheets/bootstrap/variables') + '\';\n' + iconFontPath + '\n';
'@import \'' + path.join(relativePathToBootstrap,
'scss/variables') + '\';\n';

if (config.bootstrapCustomizations) {
start += addImportReturnDependency(this, config, 'bootstrapCustomizations');
Expand All @@ -86,7 +83,7 @@ module.exports = function(content) {
source = start + partials.filter(function(partial) {
return config.styles[partial];
}).map(function(partial) {
return '@import \'' + path.join(relativePathToBootstrapSass, 'stylesheets/bootstrap',
return '@import \'' + path.join(relativePathToBootstrap, 'scss',
partial) + '\';';
}).join('\n');

Expand Down
41 changes: 20 additions & 21 deletions bootstrap-sass.config.js → bootstrap.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,63 +31,62 @@ module.exports = {
// 'css-loader!sass?outputStyle=expanded'),

scripts: {
'transition': true,
'util': true,
'alert': true,
'button': true,
'carousel': true,
'collapse': true,
'dropdown': true,
'modal': true,
'tooltip': true,
'popover': true,
'scrollspy': true,
'tab': true,
'affix': true
'tooltip': true,
'popover': true
},
styles: {
'mixins': true,

'normalize': true,
'print': true,
'glyphicons': true,

'scaffolding': true,
'reboot': true,
'type': true,
'images': true,
'code': true,
'grid': true,
'tables': true,
'forms': true,
'buttons': true,

'component-animations': true,
'dropdowns': true,
'button-groups': true,
'input-groups': true,
'navs': true,
'animation': true,
'dropdown': true,
'button-group': true,
'input-group': true,
'custom-forms': true,
'nav': true,
'navbar': true,
'breadcrumbs': true,
'card': true,
'breadcrumb': true,
'pagination': true,
'pager': true,
'labels': true,
'badges': true,
'jumbotron': true,
'thumbnails': true,
'alerts': true,
'progress-bars': true,
'alert': true,
'progress': true,
'media': true,
'list-group': true,
'panels': true,
'wells': true,
'responsive-embed': true,
'close': true,

'modals': true,
'modal': true,
'tooltip': true,
'popovers': true,
'popover': true,
'carousel': true,

'utilities': true,
'responsive-utilities': true
'utilities-background': true,
'utilities-spacing': true,
'utilities-responsive': true
}
};

14 changes: 7 additions & 7 deletions bootstrapSassPath.js → bootstrapPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ var fs = require('fs');
var path = require('path');

function bootstrapNotFound() {
var msg = 'Could not find path to bootstrap-sass. Check to see that it is in a parent ' +
'directory of config file containing node_modules/bootstrap-sass';
var msg = 'Could not find path to bootstrap. Check to see that it is in a parent ' +
'directory of config file containing node_modules/bootstrap';
console.error('ERROR: ' + msg);
throw new Error(msg);
}
Expand All @@ -20,21 +20,21 @@ function createTestParentPath(configPath, nLevelsUp) {
bootstrapNotFound();
}

return path.resolve(path.join(levelsUp, 'node_modules', 'bootstrap-sass'));
return path.resolve(path.join(levelsUp, 'node_modules', 'bootstrap'));
}

module.exports = {
getPath: function(configPath) {
var bootstrapSassParentPath;
var bootstrapParentPath;
var i = 0;
do {
bootstrapSassParentPath = createTestParentPath(configPath, i);
bootstrapParentPath = createTestParentPath(configPath, i);
i += 1;
} while (!fs.existsSync(bootstrapSassParentPath) && i < 10);
} while (!fs.existsSync(bootstrapParentPath) && i < 10);

if (i === 10) {
bootstrapNotFound();
}
return path.join(bootstrapSassParentPath, 'assets');
return bootstrapParentPath;
}
};
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require('./bootstrap-sass-no-customizations.config');
require('./bootstrap-no-customizations.config');
10 changes: 5 additions & 5 deletions index.loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ module.exports.pitch = function(remainingRequest) {
this.cacheable(true);

if (!configFilePath || configFilePath.trim() === '') {
msg = 'You specified the bootstrap-sass-loader with no configuration file. Please specify' +
' the configuration file, like: \'bootstrap-sass!./bootstrap-sass.config.js\' or use' +
' require(\'bootstrap-sass-loader\').';
msg = 'You specified the bootstrap-loader with no configuration file. Please specify' +
' the configuration file, like: \'bootstrap!./bootstrap.config.js\' or use' +
' require(\'bootstrap-loader\').';
console.error('ERROR: ' + msg);
throw new Error(msg);
}
Expand All @@ -29,9 +29,9 @@ module.exports.pitch = function(remainingRequest) {
logger.verbose(config, 'styleLoader: %s', styleLoader);

styleLoaderCommand = 'require(' + JSON.stringify('-!' + styleLoader + '!' +
require.resolve('./bootstrap-sass-styles.loader.js') + '!' + configFilePath) + ');';
require.resolve('./bootstrap-styles.loader.js') + '!' + configFilePath) + ');';
jsLoaderCommand = 'require(' + JSON.stringify('-!' +
require.resolve('./bootstrap-sass-scripts.loader.js') + '!' + configFilePath) + ');';
require.resolve('./bootstrap-scripts.loader.js') + '!' + configFilePath) + ');';
result = [styleLoaderCommand, jsLoaderCommand].join('\n');
return result;
};
Loading