css - Grunt-Sass 如何防止 CSS 解压
问题描述
我在我的项目中使用GRUNT-SASS,我使用的是 normalize.css 的缩小版本,并将它放在名为 _reset.scss 的部分上。我的问题是,GRUNT-CSS 在保存时将其转换为未压缩/美化版本(在 .css 文件中)。当我将其添加为部分 SCSS 文件中的压缩文件时,我想将其保存为压缩的 .css。有没有办法做到这一点?
这是我的 grunfile.js:
// The "wrapper" function
module.exports = function(grunt) {
const sass = require('node-sass');
// Project and task c onfiguration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
/**
* Grunt Sass
* Compile Sass to CSS using node-sass
* https://www.npmjs.com/package/grunt-sass
*/
sass: {
options: {
implementation: sass,
sourceMap: true
},
dist: {
files: {
'style.css' : 'assets/scss/main.scss'
}
}
},
/**
* Grunt Contrib Watch
* Monitor files and execute tasks
* https://www.npmjs.com/package/grunt-contrib-watch
*/
watch: {
sass: {
files: [
'assets/scss/*.scss'
],
tasks: [
'sass'
]
}
}
});
// Load all grunt tasks matching the ['grunt-*', '@*/grunt-*'] patterns
require('load-grunt-tasks')(grunt);
// Custom tasks
grunt.registerTask('default', ['watch']);
};
解决方案
推荐阅读
- android - Android Management API 的委派范围似乎没有被 Companion 应用程序获取
- sql - 如何为具有多个名称的实体设计实体表
- java - 使用 Newton-Raphson 方法计算平方根时的循环条件
- javascript - 如何使用javascript查找内联svg中预先存在的元素的(svg)位置
- flutter - 如何创建每行有 2 个列表项的列表视图
- mysql - Spark结构化流:JDBC接收器中的主键
- .net - 如何通过代码获取当前的 Azure 服务总线命名空间连接字符串
- regex - Atom 编辑器 - 使用正则表达式用标签包装文本
- javascript - 获取文本小于 1024 个字符的 reddit 帖子
- azure - Terraform local-exec Provisioner 在多个 Azure 虚拟机上运行