- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 yeoman 1.0 rc 和 grunt 来创建一个静态网站,一切都很好,但我想制作除了 css 缩小版之外,一个更新了所有文件路径的非缩小版,这是否可行,我怎么能做到这一点.
gruntfile 是一个非常标准的 grunt 文件,由 yo webapp 创建。
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// configurable paths
var yeomanConfig = {
app: 'app',
dist: 'dist'
};
grunt.initConfig({
yeoman: yeomanConfig,
watch: {
options: {
nospawn: true
},
coffee: {
files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
tasks: ['coffee:dist']
},
coffeeTest: {
files: ['test/spec/{,*/}*.coffee'],
tasks: ['coffee:test']
},
compass: {
files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
tasks: ['compass:server']
},
livereload: {
options: {
livereload: LIVERELOAD_PORT
},
files: [
'<%= yeoman.app %>/*.html',
'{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
'{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
}
},
connect: {
options: {
port: 9000,
// change this to '0.0.0.0' to access the server from outside
hostname: 'localhost'
},
livereload: {
options: {
middleware: function (connect) {
return [
mountFolder(connect, '.tmp'),
mountFolder(connect, yeomanConfig.app),
lrSnippet
];
}
}
},
test: {
options: {
middleware: function (connect) {
return [
mountFolder(connect, '.tmp'),
mountFolder(connect, 'test')
];
}
}
},
dist: {
options: {
middleware: function (connect) {
return [
mountFolder(connect, yeomanConfig.dist)
];
}
}
}
},
open: {
server: {
path: 'http://localhost:<%= connect.options.port %>'
}
},
clean: {
dist: {
files: [{
dot: true,
src: [
'.tmp',
'<%= yeoman.dist %>/*',
'!<%= yeoman.dist %>/.git*'
]
}]
},
server: '.tmp'
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'Gruntfile.js',
'<%= yeoman.app %>/scripts/{,*/}*.js',
'!<%= yeoman.app %>/scripts/vendor/*',
'test/spec/{,*/}*.js'
]
},
mocha: {
all: {
options: {
run: true,
urls: ['http://localhost:<%= connect.options.port %>/index.html']
}
}
},
coffee: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/scripts',
src: '{,*/}*.coffee',
dest: '.tmp/scripts',
ext: '.js'
}]
},
test: {
files: [{
expand: true,
cwd: 'test/spec',
src: '{,*/}*.coffee',
dest: '.tmp/spec',
ext: '.js'
}]
}
},
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: '<%= yeoman.app %>/bower_components',
httpImagesPath: '/images',
httpGeneratedImagesPath: '/images/generated',
relativeAssets: false
},
dist: {
options:{
outputStyle: 'nested'
}
},
server: {
options: {
debugInfo: true
}
}
},
// not used since Uglify task does concat,
// but still available if needed
/*concat: {
dist: {}
},*/
// not enabled since usemin task does concat and uglify
// check index.html to edit your build targets
// enable this task if you prefer defining your build targets here
/*uglify: {
dist: {}
},*/
rev: {
dist: {
files: {
src: [
'<%= yeoman.dist %>/scripts/{,*/}*.js',
'<%= yeoman.dist %>/styles/{,*/}*.css',
'<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}',
'<%= yeoman.dist %>/styles/fonts/*'
]
}
}
},
useminPrepare: {
options: {
dest: '<%= yeoman.dist %>'
},
html: '<%= yeoman.app %>/index.html'
},
usemin: {
options: {
dirs: ['<%= yeoman.dist %>']
},
html: ['<%= yeoman.dist %>/{,*/}*.html'],
css: ['<%= yeoman.dist %>/styles/{,*/}*.css']
},
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.{png,jpg,jpeg}',
dest: '<%= yeoman.dist %>/images'
}]
}
},
svgmin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.svg',
dest: '<%= yeoman.dist %>/images'
}]
}
},
cssmin: {
dist: {
files: {
'<%= yeoman.dist %>/styles/main.css': [
'.tmp/styles/{,*/}*.css',
'<%= yeoman.app %>/styles/{,*/}*.css'
]
}
}
},
htmlmin: {
dist: {
options: {
/*removeCommentsFromCDATA: true,
// https://github.com/yeoman/grunt-usemin/issues/44
//collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeOptionalTags: true*/
},
files: [{
expand: true,
cwd: '<%= yeoman.app %>',
src: '*.html',
dest: '<%= yeoman.dist %>'
}]
}
},
// Put files not handled in other tasks here
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,txt}',
'.htaccess',
'images/{,*/}*.{webp,gif}',
'styles/fonts/*'
]
}, {
expand: true,
cwd: '.tmp/images',
dest: '<%= yeoman.dist %>/images',
src: [
'generated/*'
]
}]
}
},
concurrent: {
server: [
'coffee:dist',
'compass:server'
],
test: [
'coffee',
'compass'
],
dist: [
'coffee',
'compass:dist',
'imagemin',
'svgmin',
'htmlmin'
]
}
});
grunt.registerTask('server', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'open', 'connect:dist:keepalive']);
}
grunt.task.run([
'clean:server',
'concurrent:server',
'connect:livereload',
'open',
'watch'
]);
});
grunt.registerTask('test', [
'clean:server',
'concurrent:test',
'connect:test',
'mocha'
]);
grunt.registerTask('build', [
'clean:dist',
'useminPrepare',
'concurrent:dist',
'cssmin',
'concat',
'uglify',
'copy',
'rev',
'usemin'
]);
grunt.registerTask('default', [
'jshint',
'test',
'build'
]);
最佳答案
出于生产目的,您应该始终以最少的文件数量为目标(因为最“昂贵”(时间明智)的 HTTP 正在打开连接,尤其是在移动设备上)和最小的文件大小。
意思是为生产部署“dist”文件夹。
出于测试目的,我通常部署“app”文件夹,因为这里的速度不是问题,我会在你写的时候,希望能够准确地找出问题所在的代码(css og js)。
因此,我认为只需部署“app”文件夹,直到您确定一切都如您所愿。
关于gruntjs - grunt cssmin 保留一个非缩小版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17633895/
我在包含@imports 的文件上使用cssmin。 cssmin 正确地递归地导入本地文件,但是对于指向 URL 的导入,导入是内联的。这使得生成的缩小 CSS 无效,因为 @ 规则必须位于文件的开
我正在使用 yeoman 1.0 rc 和 grunt 来创建一个静态网站,一切都很好,但我想制作除了 css 缩小版之外,一个更新了所有文件路径的非缩小版,这是否可行,我怎么能做到这一点. grun
我正在试用 cssmin咕噜声 根据文档目标可以定义“根据 grunt 配置任务指南”。 当我使用该模式创建 cssmin 任务时,例如: cssmin: { my_target: { m
我正在设置 grunt-usemin对于我们的项目,但我遇到了 cssmin 的小问题任务。 我们的项目依赖于一些外部库,其中一些会带来一些额外的 Assets (如图像或字体)。问题是这些库没有相同
在我的 Gruntfile 中,我正在使用 cssmin (grunt-contrib-cssmin) 任务。像这样的东西: cssmin: { css : { src: "d
我是 Grunt 的新手,我想知道为什么应该使用 grunt-contrib-cssmin 而不是像本例中那样创建 dev/dist 版本: sass: { dist: {
cssmin grunt 插件 grunt-contrib-cssmin 修剪 css sourcemap 源 url 中的前导斜杠,从而使 css 映射不正确。同时,在手动编辑 sourcemap
运行 grunt.js 任务时 cssMin https://github.com/gruntjs/grunt-contrib-cssmin Svg css 属性正在被删除。 例如: .testCla
我的搜索和谷歌问题没有找到任何帮助。 我在使用 Gulp 和 cssmin 时遇到问题。无法弄清楚是什么导致了错误。这个想法是将原始 css 文件和缩小版本保存在同一个文件夹中,不需要连接。我的 gu
构建没有错误,但是每个第一个 css 规则 block 都被删除了。什么会导致问题? Grunt 配置:... useminPrepare: { html: 'app/index.
我有三个文件: 'selectize.default.css' 'selectize.pagination.css' 'selectize.patch.css' 我想尽量减少它们。 这是我的 grun
我使用 cssmin 来缩小 css 文件。 我的配置是这样的: module.exports = function(grunt) { grunt.config.set('cssmin', {
我正在开发一个网络应用程序(使用 yeoman 网络应用程序生成器),我有两个 scss 基础文件,我的标准文件 (main.scss) 和我的旧版本 (main-old-ie.scss) - 使用此
我一直在寻找我的问题的解决方案,我发现有类似问题的帖子,但又不尽相同。我有以下文件夹结构: js └── GUIFramework ├── external └── WaspFrame
我在 grunt-contrib-cssmin 方面遇到了一个奇怪的问题。它永远不会停止或出错。我正在使用 C:\projects\doeclf>grunt --version && node --v
我是 gulp 的新手,需要您帮助我使用 gulp-cssmin 插件来缩小我的 CSS 文件。我的简单元素结构: gulpfile.js css/ myCss.css min/
我的 LESS 文件是使用 grunt-contrib-less 和相应的 grunt 任务编译的,配置如下: module.exports = { options: { so
在我使用 grunt-contrib-cssmin 缩小我的样式表之前,我的样式表工作正常。 这部分: *, *::before, *::after { box-sizing: inherit
我已经定义了一个 uncss grunt 任务,我想将 .min.css 添加到文件夹/css 中的所有文件内容,但是当我运行 grunt 命令并保存我的 css 更改时(任务 watch 正在查找)
我尝试使用 Grunt 和 grunt-contrib-cssmin 删除所有 CSS 注释,CSS 文件已编译并缩小,它包含所有注释。 应使用以下行删除评论:keepSpecialComments:
我是一名优秀的程序员,十分优秀!