如果您使用Grunt运行应用程序,则可以编辑Gruntfile.js文件。您正在寻找指南针部分。我发现它在第175行左右。在该部分中,您想要将Server debugInfo修改为false。
// Compiles Sass to CSS and generates necessary files if requested
compass: {
options: {
sassDir: '<%= yeoman.app %>/styles',
cssDir: '.tmp/styles',
generatedImagesDir: '.tmp/images/generated',
imagesDir: '<%= yeoman.app %>/images',
javascriptsDir: '<%= yeoman.app %>/scripts',
fontsDir: '<%= yeoman.app %>/styles/fonts',
importPath: './bower_components',
httpImagesPath: '/images',
httpGeneratedImagesPath: '/images/generated',
httpFontsPath: '/styles/fonts',
relativeAssets: false,
assetCacheBuster: false,
raw: 'Sass::Script::Number.precision = 10\n'
},
dist: {
options: {
generatedImagesDir: '<%= yeoman.dist %>/images/generated'
}
},
server: {
options: {
debugInfo: false
}
}
},
通过将选项更改为false,您将不会在文件中具有调试信息。我建议您在开发过程中保留调试信息。当网站完成并准备好生产时,请删除调试信息。
最后,这不会将注释从CSS文件中移除。您可能会注意到Compass会在每个选择器的开头插入位置注释。 (见下文)
/* line 19, ../../bower_components/bootstrap-sass-official/assets/stylesheets/bootstrap/_normalize.scss */
body { margin: 0; }
为了消除这种情况,您需要使用缩小。咕噜也可以照顾。您需要确保已配置Gruntfile.js。 (我找到了我与//每行前注释掉。我不得不删除这些行),之后只需运行
grunt cssmin
这2步花了475 KB CSS文件下降到110 KB。
希望这会有所帮助!
此外,当您与做你的产品,并准备上传,只需运行“grunt build”即可运行所有最小化操作,包括cuss,html,JavaScript等,并将其放入“dist”文件夹中。只需将dist文件夹的内容上传到根文件夹,即可开始使用! – 2014-11-18 07:18:57