简体   繁体   English

grunt mini css html js:只需复制到目标文件

[英]grunt mini css html js: just copy to dest for some file

i'm use grunt task for minify static file like js,css,html. 我正在使用grunt任务来最小化js,css,html之类的静态文件。

but when i execute the task, i found some problem. 但是当我执行任务时,我发现了一些问题。

if in the css floder,include some gif for use. 如果在css floder中,请包含一些gif以供使用。 then those file con't build to dest direct. 那么这些文件就不会直接建立。

if i don't want use copy plugin. 如果我不想使用复制插件。

do u have any ideas for this case? 您对此案有什么想法吗?

  uglify: {
        build: {
            expand: true,
            cwd: 'src/js',
            src: '**/*.js',
            dest: 'dist/js'
        }
    },
    cssmin: {
        minify: {
            expand: true,
            cwd: 'src/css/',
            src: ['*.css', '**/*.css'],//, '!*.min.css'
            dest: 'dist/css/'
        }
    }

cssmin and uglify won't copy your gif assets, you have to do this using grunt's copy task, with configuration like this cssmin和uglify不会复制您的gif资产,您必须使用grunt的复制任务来执行此操作,并具有如下配置

copy: {
  assets: {
    expand: true,
    cwd: 'src/css',
    dest: 'dist/css',
    src: '**/*.{gif,png,jpg}'
  },
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM