使用 GruntJS 删除旧文件
Using GruntJS to delete old files
世界人民大家好。我一直在尝试为静态 Web 应用程序自动化我的 grunt 工作区。下面是我的文件结构的示例。我当前的 grunt 安装程序监视 src 文件夹中文件的更改,如果有更改,它仅处理和更新使用 grunt-newer 更改的文件,并将它们放入缩小文件夹中。
假设我从 src 文件夹中删除了 styles.scss。然后我还需要相应的 styles.css 才能删除。有什么办法可以用 Grunt 自动完成吗?如上问题所示,我还需要它知道minified文件夹中的styles.css对应src文件夹中的styles.scss
文件结构:
-
来源
-
styles.scss
-
index.haml
-
缩小
-
styles.css
-
file.html
编辑:像这样的东西:https://github.com/tschaub/grunt-newer/issues/15
请注意,该问题没有解决方案
你可以在你的 GruntFile 上做这样的事情:
sass: {
dist: {
files: {
'style/style.css' : 'sass/style.scss'
}
}
},
watch: {
css: {
files: '**/*.scss',
tasks: ['clean','sass'],
options: {
event: ['deleted'],
},
}
},
clean: {
dist: {
files: [{
src: [
'dist/*.css'
]
}]
}
}
因为它,如果您删除(并且只删除)一个 .saas 文件,您的 dist 文件夹将被自动清理并重建您的 sass 文件。
它使用:
- 咕噜手表:https://github.com/gruntjs/grunt-contrib-watch
- 咕噜萨斯:https://github.com/gruntjs/grunt-contrib-sass
- 咕噜干净:https://github.com/gruntjs/grunt-contrib-clean
一个不错的教程:http://ryanchristiani.com/getting-started-with-grunt-and-sass/
希望对您有所帮助!
世界人民大家好。我一直在尝试为静态 Web 应用程序自动化我的 grunt 工作区。下面是我的文件结构的示例。我当前的 grunt 安装程序监视 src 文件夹中文件的更改,如果有更改,它仅处理和更新使用 grunt-newer 更改的文件,并将它们放入缩小文件夹中。
假设我从 src 文件夹中删除了 styles.scss。然后我还需要相应的 styles.css 才能删除。有什么办法可以用 Grunt 自动完成吗?如上问题所示,我还需要它知道minified文件夹中的styles.css对应src文件夹中的styles.scss
文件结构:
-
来源
- styles.scss
- index.haml
-
缩小
- styles.css
- file.html
编辑:像这样的东西:https://github.com/tschaub/grunt-newer/issues/15 请注意,该问题没有解决方案
你可以在你的 GruntFile 上做这样的事情:
sass: {
dist: {
files: {
'style/style.css' : 'sass/style.scss'
}
}
},
watch: {
css: {
files: '**/*.scss',
tasks: ['clean','sass'],
options: {
event: ['deleted'],
},
}
},
clean: {
dist: {
files: [{
src: [
'dist/*.css'
]
}]
}
}
因为它,如果您删除(并且只删除)一个 .saas 文件,您的 dist 文件夹将被自动清理并重建您的 sass 文件。
它使用:
- 咕噜手表:https://github.com/gruntjs/grunt-contrib-watch
- 咕噜萨斯:https://github.com/gruntjs/grunt-contrib-sass
- 咕噜干净:https://github.com/gruntjs/grunt-contrib-clean
一个不错的教程:http://ryanchristiani.com/getting-started-with-grunt-and-sass/
希望对您有所帮助!