【问题标题】:Gulp and elixir copy folders and minify themGulp 和 elixir 复制文件夹并缩小它们
【发布时间】:2017-01-05 12:34:51
【问题描述】:

目前在我们的gulpfile.js 中,每个 JS 文件都被 .scripts() 编辑。

我们希望从每个文件转移到更合乎逻辑的文件。使用类似 foreach 循环的方式遍历给定目录中的所有 javascript 文件,将它们复制到 public/js,然后使用任何插件将它们缩小,然后 .version() 将它们放在构建文件夹中。

你怎么能foreach所有这些文件,什么是缩小文件+版本的合乎逻辑的步骤?

【问题讨论】:

    标签: javascript laravel gulp laravel-elixir


    【解决方案1】:

    要连接和缩小,这样做

    // first arg is an array of files, relative to /resources/assets/js/ 
    // second arg is the destination
    mix.scripts([
      '/../bower/jquery/dist/jquery.min.js',
      '/myfile.js',
    ], 
    'public/js/deps.js');
    

    虽然只有在运行gulp --production 时才会发生缩小。

    要对资产进行版本控制,请在您的视图中使用 elixir() 助手。 It's in the docs

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-19
      • 2016-05-08
      • 2011-08-04
      相关资源
      最近更新 更多