Невозможно скомпилировать Bootstrap css с помощью grunt - PullRequest
0 голосов
/ 24 мая 2018

Для этого есть много онлайн-уроков, но после двух дней борьбы - мне нужна помощь.Я пытаюсь добавить пространство имен в Bootstrap, чтобы я мог использовать его в Salesforce, не вмешиваясь в таблицу стилей Salesforce.Моя цель - обернуть bootstrap.less в .bs {}, чтобы я мог ссылаться на него на своей странице как на ресурс.Кажется, что несмотря ни на что, bootstrap.css не компилируется.

Bootstrap Test v2
├───bootstrap-3.3.7
    ├───Gruntfile.js
    |───dist
    |     |───css
    |          |───bootstrap.css
    |───less
          |───bootstrap.less

Шаги для воспроизведения:

1) Изменить bootstrap.less (обернуть содержимое с помощью .bs {})

2) Перейдите к Bootstrap Test V2

3) выполнить команду 'grunt dist'

вывод:

C:\Users\json\Desktop\Bootstrap\Bootstrap Test v2>grunt dist
(node:8444) ExperimentalWarning: The http2 module is an experimental API.
Running "clean:dist" (clean) task
>> 1 path cleaned.

Running "less:compileCore" (less) task
>> 1 stylesheet created.
>> 1 sourcemap created.

Running "less:compileTheme" (less) task
>> 1 stylesheet created.
>> 1 sourcemap created.

Running "autoprefixer:core" (autoprefixer) task
>> 1 autoprefixed stylesheet created.
>> 1 sourcemap created.

Running "autoprefixer:theme" (autoprefixer) task
>> 1 autoprefixed stylesheet created.
>> 1 sourcemap created.

Running "csscomb:dist" (csscomb) task
>> Using custom config file "less/.csscomb.json"...
>> Sorting file "dist/css/bootstrap-theme.css"...
>> Sorting file "dist/css/bootstrap.css"...

Running "cssmin:minifyCore" (cssmin) task
>> 1 sourcemap created.
>> 1 file created. 146.01 kB → 121.2 kB

Running "cssmin:minifyTheme" (cssmin) task
>> 1 sourcemap created.
>> 1 file created. 26.13 kB → 23.41 kB

Running "copy:fonts" (copy) task
Created 1 directory, copied 5 files

Running "concat:bootstrap" (concat) task

Running "uglify:core" (uglify) task
File dist/js/bootstrap.min.js created: 69.71 kB → 37.05 kB
>> 1 file created.

Running "commonjs" task
File dist/js/npm.js created.

Done.


Execution Time (2018-05-23 23:58:31 UTC+3)
clean:dist           77ms  █ 2%
less:compileCore    994ms  ███████████ 25%
less:compileTheme   146ms  ██ 4%
autoprefixer:core   538ms  ██████ 14%
autoprefixer:theme   90ms  █ 2%
csscomb:dist         1.1s  ████████████ 28%
cssmin:minifyCore   421ms  █████ 11%
cssmin:minifyTheme   53ms  █ 1%
copy:fonts           48ms  █ 1%
uglify:core         427ms  █████ 11%
Total 3.9s

gruntfile:

module.exports = function(grunt) {
  require('jit-grunt')(grunt);

  grunt.initConfig({
    less: {
      development: {
        options: {
          compress: true,
          yuicompress: true,
          optimization: 2
        },
        files: {
          "dist/css/bootstraptest.css": "less/bootstrap.less" // destination file and source file
        }
      }
    },
    watch: {
      styles: {
        files: ['less/**/*.less'], // which files to watch
        tasks: ['less'],
        options: {
          nospawn: true
        }
      }
    }
  });

  grunt.registerTask('default', ['less', 'watch']);
};

     module.exports = function(grunt) {
         grunt.initConfig({

             less: {
                 development: {
                     options: {
                         paths: ["assets/css"]
                     },
                     files: {"dist/css/bootstrap.css": "less/bootstrap.less"}
                 },
                 production: {
                     options: {
                         paths: ["assets/css"],
                         cleancss: true
                     },
                     files: {"dist/css/bootstrap.css": "less/bootstrap.less"}
                 }
             }
         });
         grunt.loadNpmTasks('grunt-contrib-less');
         grunt.registerTask('default', ['less']);
     };

Примечания: 1) Использование команды 'grunt' isnне работает для меня, он выдает ошибку «Запуск задачи« jekyll: docs »(jekyll)» и предлагает скачать jekyll, который я уже установил.Я читал в Интернете, что 'grunt dist' должно быть достаточно - это правильно?

1 Ответ

0 голосов
/ 01 июня 2018

Использование 'командной строки node js' вместо обычной командной строки помогло мне.

Windoes: Start> Node.js, командная строка

Я следовал инструкциям в этой статье, и она наконец заработала.

...