2016-12-05 56 views
1

問題是我無法將.css文件最小化爲dist文件夾。 當我運行命令'grunt'時,出現以下錯誤。幫我。提前致謝。Grunt:Css文件不會最小化

Running "concat:dist" (concat) task 

Running "cssmin:dist" (cssmin) task 
>> No files created. 

Running "uglify:dist" (uglify) task 
>> No files created. 

Running "copy:dist" (copy) task 


Running "copy:fonts" (copy) task 

我的HTML文件頭和Grunt.js的代碼如下:

'use strict'; 
 

 
module.exports = function (grunt) { 
 
    // Define the configuration for all the tasks 
 
    \t // Time how long tasks take. Can help when optimizing build times 
 
    \t require('time-grunt')(grunt); 
 

 
    \t // Automatically load required Grunt tasks 
 
    \t require('jit-grunt')(grunt, { 
 
    \t useminPrepare: 'grunt-usemin' 
 
    \t }); 
 
    \t // Define the configuration for all the tasks 
 
    \t grunt.initConfig({ 
 
    \t pkg: grunt.file.readJSON('package.json'), 
 

 
    \t // Make sure code styles are up to par and there are no obvious mistakes 
 
    \t jshint: { 
 
    \t  options: { 
 
    \t  jshintrc: '.jshintrc', 
 
    \t  reporter: require('jshint-stylish') 
 
    \t  }, 
 
    \t  
 
    \t  all: { 
 
    \t  src: [ 
 
    \t   'Gruntfile.js', 
 
    \t   'app/scripts/{,*/}*.js' 
 
    \t  ] 
 
    \t  } 
 
    \t }, 
 
    \t copy: { 
 
    \t  dist: { 
 
    \t  cwd: 'app', 
 
    \t  src: [ '**','!styles/**/*.css','!scripts/**/*.js' ], 
 
    \t  dest: 'dist', 
 
    \t  expand: true 
 
    \t  }, 
 
    \t  
 
    \t  fonts: { 
 
    \t  files: [ 
 
    \t   { 
 
    \t   //for bootstrap fonts 
 
    \t   expand: true, 
 
    \t   dot: true, 
 
    \t   cwd: 'bower_components/bootstrap/dist', 
 
    \t   src: ['fonts/*.*'], 
 
    \t   dest: 'dist' 
 
    \t   }, { 
 
    \t   //for font-awesome 
 
    \t   expand: true, 
 
    \t   dot: true, 
 
    \t   cwd: 'bower_components/font-awesome', 
 
    \t   src: ['fonts/*.*'], 
 
    \t   dest: 'dist' 
 
    \t   } 
 
    \t  ] 
 
    \t  } 
 
    \t }, 
 

 
    \t clean: { 
 
    \t  build: { 
 
    \t  src: [ 'dist/'] 
 
    \t  } 
 
    \t }, 
 

 

 
    \t useminPrepare: { 
 
    \t html: 'app/detail.html', 
 
    \t options: { 
 
    \t  dest: 'dist' 
 
    \t } 
 
    \t }, 
 

 
    \t // Concat 
 
    \t concat: { 
 
    \t options: { 
 
    \t  separator: ';' 
 
    \t }, 
 
    \t 
 
    \t // dist configuration is provided by useminPrepare 
 
    \t dist: {} 
 
    \t }, 
 

 
    \t // Uglify 
 
    \t uglify: { 
 
    \t // dist configuration is provided by useminPrepare 
 
    \t dist: {} 
 
    \t }, 
 

 
    \t cssmin: { 
 
    \t dist: {} 
 
    \t }, 
 

 
    \t // Filerev 
 
    \t filerev: { 
 
    \t options: { 
 
    \t  encoding: 'utf8', 
 
    \t  algorithm: 'md5', 
 
    \t  length: 20 
 
    \t }, 
 
    \t 
 
    \t release: { 
 
    \t  // filerev:release hashes(md5) all assets (images, js and css) 
 
    \t  // in dist directory 
 
    \t  files: [{ 
 
    \t  src: [ 
 
    \t   'dist/scripts/*.js', 
 
    \t   'dist/styles/*.css', 
 
    \t  ] 
 
    \t  }] 
 
    \t } 
 
    \t }, 
 
    \t 
 
    \t // Usemin 
 
    \t // Replaces all assets with their revved version in html and css files. 
 
    \t // options.assetDirs contains the directories for finding the assets 
 
    \t // according to their relative paths 
 
    \t usemin: { 
 
    \t html: ['dist/*.html'], 
 
    \t css: ['dist/styles/*.css'], 
 
    \t options: { 
 
    \t  assetsDirs: ['dist', 'dist/styles'] 
 
    \t } 
 
    \t } 
 
    \t }); 
 

 
    \t grunt.registerTask('build', [ 
 
    \t 'clean', 
 
    \t 'jshint', 
 
    \t 'useminPrepare', 
 
    \t 'concat', 
 
    \t 'cssmin', 
 
    \t 'uglify', 
 
    \t 'copy', 
 
    \t 'filerev', 
 
    \t 'usemin' 
 
    \t ]); 
 
    \t grunt.registerTask('default',['build']); 
 

 
}; \t
<head> 
 
    <title>Angular JS</title> 
 

 
    <!-- build:css styles/main.css --> 
 
    <link href="../bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> 
 
    <link href="../bower_components/bootstrap/dist/css/bootstrap-theme.min.css" rel="stylesheet"> 
 
    <link href="../bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet"> 
 
    <link href="styles/bootstrap-social.css" rel="stylesheet"> 
 
    <link href="styles/mystyles.css" rel="stylesheet"> 
 
    <!-- endbuild --> 
 
</head>

回答