2017-05-31 9 views
2

GruntJS + SASSコンパスに問題があります。私はdevprodの設定をセットアップしました。 devの場合、outputStyle: 'expanded'prodの場合はoutputStyle: 'compressed'です。私がprodをやっているとき、それは魅力のように働く。コンソールで私は参照してくださいグランツコンパスデベロッパー

Running "compass:dist" (compass) task 
overwrite css/screen.css (0.392s) 
Compilation took 0.4s 

css圧縮する必要がありますように。

しかし、私はそれがコンソール何

Running "compass:dev" (compass) task 

Running "autoprefixer:dist" (autoprefixer) task 

とCSS圧縮静止に示しdevやっています。

私Gruntfile.jsの設定があります:

module.exports = function(grunt) { 
grunt.initConfig({ 
    pkg: grunt.file.readJSON('package.json'), 

    compass: { 
     dev: { 
      options: { 
       sassDir: 'sass', 
       cssDir: 'css', 
       imagesDir: 'images', 
       fontsDir: 'fonts', 
       relativeAssets: true, 
       boring: true, 
       outputStyle: 'expanded', 
       environment: 'development', 
       raw: 'preferred_syntax = :sass\n' 
      } 
     }, 
     dist: { 
      options: { 
       sassDir: 'sass', 
       cssDir: 'css', 
       imagesDir: 'images', 
       fontsDir: 'fonts', 
       relativeAssets: true, 
       boring: true, 
       force: true, 
       bundleExec: true, 
       outputStyle: 'compressed', 
       environment: 'production', 
       raw: 'preferred_syntax = :sass\n' 
      } 
     } 
    }, 

    autoprefixer: { 
     dist:{ 
      files:{ 
       'css/screen.css':'css/screen.css' 
      } 
     } 
    }, 

    concat: { 
     dist: { 
      src: [ 
       'js/vendors/filename.js', 
       'js/companyname/filename.js' 
      ], 
      dest: 'js/companyname/main.js' 
     } 
    }, 

    jshint: { 
     all: ['Gruntfile.js'], 
     beforeconcat: [ 
      'js/src/companyname/app.js', 
      'js/src/companyname/bar.js' 
     ] 
    }, 

    uglify: { 
     options: { 
      mangle: false 
     }, 
     prod: { 
      files: [{ 
       expand: true, 
       cwd: 'js', 
       src: [ 
        'vendors/**/*.js', 
        'companyname/**/*.js' 
       ], 
       dest: 'js' 
      }] 
     } 
    }, 

    copy: { 
     main: { 
      expand: true, 
      cwd: 'js/src', 
      src: [ 
       'companyname/**/*.js', 
       'vendors/**/*.js' 
      ], 
      dest: 'js/' 
     } 
    }, 

    imagemin: { 
     jpg: { 
      options: { 
       optimizationLevel: 8 
      }, 
      files: [ 
       { 
        expand: true, 
        cwd: 'images-src/', 
        src: ['**/*.jpg'], 
        dest: 'images/', 
        ext: '.jpg' 
       } 
      ] 
     }, 
     png: { 
      options: { 
       optimizationLevel: 8 
      }, 
      files: [ 
       { 
        expand: true, 
        cwd: 'images-src/', 
        src: ['**/*.png'], 
        dest: 'images/', 
        ext: '.png' 
       } 
      ] 
     } 
    }, 

    clean: { 
     images: { 
      src: ['images'] 
     } 
    }, 

    watch: { 
     compass: { 
      files: [ 
       'sass/{,*/}*.sass', 
       'images-src/{,*/}*.{png,jpg,gif}' 
      ], 
      tasks: [ 
       'compass:dev', 
       'autoprefixer', 
       'clean:images', 
       'imagemin' 
      ] 
     } 
    } 
}); 

grunt.loadNpmTasks('grunt-contrib-compass'); 
grunt.loadNpmTasks('grunt-contrib-imagemin'); 
grunt.loadNpmTasks('grunt-contrib-clean'); 
grunt.loadNpmTasks('grunt-contrib-concat'); 
grunt.loadNpmTasks('grunt-contrib-jshint'); 
grunt.loadNpmTasks('grunt-contrib-uglify'); 
grunt.loadNpmTasks('grunt-contrib-copy'); 
grunt.loadNpmTasks('grunt-autoprefixer'); 
grunt.loadNpmTasks('grunt-contrib-watch'); 

grunt.registerTask('default', [ 
    'compass:dev', 
    'autoprefixer', 
    'copy', 
    'concat', 
    'jshint', 
    'uglify' 
]); 

grunt.registerTask('prod', [ 
    'compass:dist', 
    'autoprefixer', 
    'copy', 
    'concat', 
    'jshint', 
    'uglify', 
    'clean:images', 
    'imagemin' 
]); 
}; 

私が間違ってやっていますか?

答えて

1

あなたは2つの異なるコンパス開発者を作ることができます。

compass: { 
    dev: { 
    ... 
    force: true 
    ... 
    }, 
    devWatch: { 
    ... ur original ... 
    } 
} 

watch(compass: {tasks: ['compass:devWatch', ...]}) 

grunt.registerTask('watch', [ 
    'compass:dev', 
    'watch' 
]); 

grunt.registerTask('dev', [ 
    'compass:dev' 
]); 
+0

ありがとうございます!あなたの答えはバグを見つけるのに役立ちました。私はdevのタスクに 'force:true'を追加するのを忘れていました。残りは魅力のような作品です。 – Oleg