【问题标题】:Concat a single file to every file in a directory using grunt使用 grunt 将单个文件连接到目录中的每个文件
【发布时间】:2013-07-11 19:56:37
【问题描述】:

使用 Grunt,我想将一个文件连接到构建目录中的所有文件。这样做的目的是将 IE 特定的 CSS 文件附加(或可能预先附加)到构建 CSS 文件中。

要完成这个任务:

build/
  file1.css
  file2.css
  file3.css

然后创建这个:

build/
  file1.css
  file1.ie.css
  file2.css
  file2.ie.css
  file3.css
  file3.ie.css

我认为扩展选项可能是我正在寻找的,但我不知道如何让它做我想做的事。

【问题讨论】:

  • 您如何确定哪些文件被连接在一起?此外,您的应用程序/网站的结构中的哪个位置是 IE 特定文件?
  • IE 特定文件位于构建目录旁边,在 css 目录中。我想将ie文件附加到build目录下的所有文件中。

标签: javascript gruntjs grunt-contrib-concat


【解决方案1】:

尝试grunt-contrib-concat 中的banner 选项:

concat: {
  dist: {
    options: {
      banner: '/* IE specific things here */',
    },
    expand: true,
    cwd: 'build/',
    ext: '.ie.css',
    src: ['**/*.css'],
    dest: 'build/',
  },
},

【讨论】:

  • 啊,好主意! footer 也可能是一个不错的选择。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-08
相关资源
最近更新 更多