Elixir不会缩小和组合

时间:2016-03-03 19:31:23

标签: laravel gulp laravel-elixir

你好我试图缩小并将我的文件合并到一个js和css文件中,但是当我运行gulp时它不起作用--production my gulpfile.js

var elixir = require('laravel-elixir');

elixir(function(mix) {
     /**
     * Copy needed files from /node directories
     * to /public directory.
     */
    mix.copy(
       'node_modules/font-awesome/fonts',
       'public/build/fonts/font-awesome'
     )
    mix.copy(
       'node_modules/bootstrap-sass/assets/fonts/bootstrap',
       'public/build/fonts/bootstrap'
     )
    mix.copy(
       'node_modules/bootstrap-sass/assets/javascripts/bootstrap.min.js',
       'public/js/vendor/bootstrap'
     )

    mix.styles(['frontend.css', 'style.css', 'responsive.css'], 'public/build/css/frontend.css', 'public/css')
    .styles(['backend.css'], 'public/build/css/backend.css', 'public/css');
    mix.scripts(['frontend.js'], 'public/build/js/frontend.js' , 'public/js')
    .scripts(['backend.js'], 'public/build/js/backend.js', 'public/js');

    mix.version(["public/css/frontend.css", "public/js/frontend.js", "public/css/backend.css", "public/js/backend.js"]);
});

和我的控制台输出

➜  public_html gulp --production
[19:29:22] Using gulpfile /home/admin/web/***.com/public_html/gulpfile.js
[19:29:22] Starting 'default'...
[19:29:22] Starting 'copy'...

Fetching Copy Source Files...
   - node_modules/font-awesome/fonts/**/*


Saving To...
   - public/build/fonts/font-awesome

[19:29:22] Finished 'default' after 49 ms
[19:29:22] Finished 'copy' after 80 ms
[19:29:22] Starting 'copy'...

Fetching Copy Source Files...
   - node_modules/bootstrap-sass/assets/fonts/bootstrap/**/*


Saving To...
   - public/build/fonts/bootstrap

[19:29:22] Finished 'copy' after 8.26 ms
[19:29:22] Starting 'copy'...

Fetching Copy Source Files...
   - node_modules/bootstrap-sass/assets/javascripts/bootstrap.min.js


Saving To...
   - public/js/vendor/bootstrap

[19:29:22] Finished 'copy' after 3.33 ms
[19:29:22] Starting 'styles'...

Fetching Styles Source Files...
   - public/css/frontend.css
   - public/css/style.css
   - public/css/responsive.css


Saving To...
   - public/build/css/frontend.css

[19:29:29] gulp-notify: [Laravel Elixir] Stylesheets Merged!
[19:29:29] Finished 'styles' after 7.12 s
[19:29:29] Starting 'styles'...

Fetching Styles Source Files...
   - public/css/backend.css


Saving To...
   - public/build/css/backend.css

[19:29:40] gulp-notify: [Laravel Elixir] Stylesheets Merged!
[19:29:40] Finished 'styles' after 11 s
[19:29:40] Starting 'scripts'...

Fetching Scripts Source Files...
   - public/js/frontend.js


Saving To...
   - public/build/js/frontend.js

[19:29:40] gulp-notify: [Laravel Elixir] Scripts Merged!
[19:29:40] Finished 'scripts' after 866 ms
[19:29:40] Starting 'scripts'...

Fetching Scripts Source Files...
   - public/js/backend.js


Saving To...
   - public/build/js/backend.js

[19:29:41] gulp-notify: [Laravel Elixir] Scripts Merged!
[19:29:41] Finished 'scripts' after 610 ms
[19:29:41] Starting 'version'...

Fetching Version Source Files...
   - public/css/frontend.css
   - public/js/frontend.js
   - public/css/backend.css
   - public/js/backend.js


Saving To...
   - public/build

[19:29:41] Finished 'version' after 52 ms

基本上它应该缩小并将css和js文件合并到一个css和js文件中

但是style.css和responsive.css没有合并到frontend.css文件中

请帮助我做错了什么?

1 个答案:

答案 0 :(得分:1)

您正在对错误的文件进行版本控制。您需要在构建文件夹public / build /...

中对文件进行版本控制

一般来说,作为一种良好的做法'为了阻止这样的事情发生,组合styles / js文件的结果不应该与其中一个组件部分同名。此问题是由命名输入文件frontend.css以及输出文件frontend.css引起的。如果你使用像all.css或app.css这样的东西作为输出文件

,它会更好