0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-29 21:52:22 +01:00

Move node-sass to npm script and drop Ruby Sass.

This commit is contained in:
Bardi Harborow 2017-01-03 11:46:57 +11:00
parent 56f917dd8c
commit 450ef91b7d
5 changed files with 12 additions and 95 deletions

View File

@ -226,6 +226,12 @@ module.exports = function (grunt) {
htmlhint: {
command: 'npm run htmlhint'
},
sass: {
command: 'npm run sass'
},
'sass-docs': {
command: 'npm run sass-docs'
},
'scss-lint': {
command: 'npm run scss-lint'
},
@ -278,9 +284,7 @@ module.exports = function (grunt) {
// These plugins provide necessary tasks.
require('load-grunt-tasks')(grunt, { scope: 'devDependencies',
// Exclude Sass compilers. We choose the one to load later on.
pattern: ['grunt-*', '!grunt-sass', '!grunt-contrib-sass'] })
require('load-grunt-tasks')(grunt)
require('time-grunt')(grunt)
// Docs HTML validation task
@ -324,15 +328,10 @@ module.exports = function (grunt) {
// JS distribution task.
grunt.registerTask('dist-js', ['babel:dev', 'concat', 'babel:dist', 'stamp', 'exec:uglify'])
grunt.registerTask('test-scss', ['exec:scss-lint']);
grunt.registerTask('test-scss', ['exec:scss-lint'])
// CSS distribution task.
// Supported Compilers: sass (Ruby) and libsass.
(function (sassCompilerName) {
require('./grunt/bs-sass-compile/' + sassCompilerName + '.js')(grunt)
}(process.env.TWBS_SASS || 'libsass'))
// grunt.registerTask('sass-compile', ['sass:core', 'sass:extras', 'sass:docs']);
grunt.registerTask('sass-compile', ['sass:core', 'sass:extras', 'sass:docs'])
grunt.registerTask('sass-compile', ['exec:sass', 'exec:sass-docs'])
grunt.registerTask('dist-css', ['sass-compile', 'exec:postcss', 'exec:clean-css', 'exec:clean-css-docs'])

View File

@ -39,15 +39,6 @@ Our Gruntfile includes the following commands and tasks:
| `grunt docs` | Builds and tests CSS, JavaScript, and other assets which are used when running the documentation locally via `jekyll serve`. |
| `grunt watch` | This is a convenience method for watching just Sass files and automatically building them whenever you save. |
## Switching Sass compilers
Bootstrap will be compiled with [libsass][libsass] by default, but you can opt into traditional Ruby Sass by setting the `TWBS_SASS` environment variable. Two options are supported:
* `libsass` (default) to use [libsass][libsass] via [grunt-sass][grunt-sass].
* `sass` to use [Ruby Sass][ruby-sass] via [grunt-contrib-sass][grunt-contrib-sass].
For example, run `TWBS_SASS=sass grunt` to test and build Bootstrap with Ruby Sass.
## Autoprefixer
Bootstrap uses [Autoprefixer][autoprefixer] (included in our Gruntfile and build process) to automatically add vendor prefixes to some CSS properties at build time. Doing so saves us time and code by allowing us to write key parts of our CSS a single time while eliminating the need for vendor mixins like those found in v3.
@ -68,8 +59,4 @@ Learn more about using Jekyll by reading its [documentation](https://jekyllrb.co
Should you encounter problems with installing dependencies or running Grunt commands, uninstall all previous dependency versions (global and local). Then, rerun `npm install`.
[ruby-sass]: https://github.com/sass/sass
[grunt-contrib-sass]: https://github.com/gruntjs/grunt-contrib-sass
[libsass]: https://github.com/sass/libsass
[grunt-sass]: https://github.com/sindresorhus/grunt-sass
[autoprefixer]: https://github.com/postcss/autoprefixer

View File

@ -1,33 +0,0 @@
// Compile Bootstrap with [libsass][1] using [grunt-sass][2]
// [1]: https://github.com/sass/libsass
// [2]: https://github.com/sindresorhus/grunt-sass
module.exports = function configureLibsass(grunt) {
grunt.config.merge({
sass: {
options: {
includePaths: ['scss'],
precision: 6,
sourceComments: false,
sourceMap: true,
outputStyle: 'expanded'
},
core: {
files: {
'dist/css/<%= pkg.name %>.css': 'scss/<%= pkg.name %>.scss'
}
},
extras: {
files: {
'dist/css/<%= pkg.name %>-grid.css': 'scss/<%= pkg.name %>-grid.scss',
'dist/css/<%= pkg.name %>-reboot.css': 'scss/<%= pkg.name %>-reboot.scss'
}
},
docs: {
files: {
'docs/assets/css/docs.min.css': 'docs/assets/scss/docs.scss'
}
}
}
})
grunt.loadNpmTasks('grunt-sass')
}

View File

@ -1,37 +0,0 @@
// Compile Bootstrap with [Ruby Sass][1] using [grunt-contrib-sass][2]
// [1]: https://github.com/sass/sass
// [2]: https://github.com/gruntjs/grunt-contrib-sass
module.exports = function configureRubySass(grunt) {
var options = {
loadPath: ['scss'],
precision: 6,
sourcemap: 'auto',
style: 'expanded',
trace: true,
bundleExec: true
}
grunt.config.merge({
sass: {
core: {
options: options,
files: {
'dist/css/<%= pkg.name %>.css': 'scss/<%= pkg.name %>.scss'
}
},
extras: {
options: options,
files: {
'dist/css/<%= pkg.name %>-grid.css': 'scss/<%= pkg.name %>-grid.scss',
'dist/css/<%= pkg.name %>-reboot.css': 'scss/<%= pkg.name %>-reboot.scss'
}
},
docs: {
options: options,
files: {
'docs/assets/css/docs.min.css': 'docs/assets/scss/docs.scss'
}
}
}
})
grunt.loadNpmTasks('grunt-contrib-sass')
}

View File

@ -24,6 +24,8 @@
"htmlhint": "htmlhint --config docs/.htmlhintrc _gh_pages/",
"postcss": "postcss --config grunt/postcss.js --replace dist/css/*.css",
"postcss-docs": "postcss --config grunt/postcss.js --no-map --replace docs/assets/css/docs.min.css && postcss --config grunt/postcss.js --no-map --replace docs/examples/**/*.css",
"sass": "node-sass --output-style expanded --source-map true --precision 6 scss/bootstrap.scss dist/css/bootstrap.css && node-sass --output-style expanded --source-map true --precision 6 scss/bootstrap-grid.scss dist/css/bootstrap-grid.css && node-sass --output-style expanded --source-map true --precision 6 scss/bootstrap-reboot.scss dist/css/bootstrap-reboot.css",
"sass-docs": "node-sass --output-style expanded --source-map true --precision 6 docs/assets/scss/docs.scss docs/assets/css/docs.min.css",
"scss-lint": "bundle exec scss-lint --config scss/.scss-lint.yml --exclude scss/_normalize.scss scss/*.scss",
"scss-lint-docs": "bundle exec scss-lint --config scss/.scss-lint.yml --exclude docs/assets/scss/docs.scss docs/assets/scss/*.scss",
"uglify": "uglifyjs --compress warnings=false --mangle --comments '/^!/' --output dist/js/bootstrap.min.js dist/js/bootstrap.js",
@ -62,17 +64,16 @@
"grunt-contrib-connect": "^1.0.2",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-qunit": "^1.2.0",
"grunt-contrib-sass": "^1.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-exec": "^1.0.1",
"grunt-html": "^8.0.2",
"grunt-jekyll": "^0.4.4",
"grunt-sass": "2.0.0",
"grunt-saucelabs": "^9.0.0",
"grunt-stamp": "^0.3.0",
"htmlhint": "^0.9.13",
"is-travis": "^1.0.0",
"load-grunt-tasks": "^3.5.2",
"node-sass": "^4.1.1",
"postcss-cli": "^2.6.0",
"postcss-flexbugs-fixes": "^2.0.0",
"shelljs": "^0.7.4",