Search code examples
laravel-5laravel-elixir

Laravel 5 and Elixir - point to wrong directory


I have a simple script to combine the styles:

elixir(function(mix) {
    mix.styles([
        'bootstrap.min.css',
        'font-awesome.css',
        'animate.css',
        'style.css'
    ], "public/frontend/css");
});

All my css file are in public/frontend/css directory and I set the second argument of the styles function to that base but if I run gulp I get:

[19:18:22] Starting 'default'...
[19:18:22] Starting 'styles'...
[19:18:22] Merging: resources/css/css/bootstrap.min.css,resources/css/public/frontend/css/font-awesome.css,resources/css/public/frontend/css/animate.css,resources/css/public/frontend/css/style.css
[19:18:22] Finished 'default' after 196 ms
[19:18:22] File not found: resources/css/css/bootstrap.min.css
[19:18:22] File not found: resources/css/public/frontend/css/font-awesome.css
[19:18:22] File not found: resources/css/public/frontend/css/animate.css
[19:18:22] File not found: resources/css/public/frontend/css/style.css
[19:18:22] Finished 'styles' after 206 ms

So it sets the base directory to resources/css.

How can I solve?


Solution

  • EDIT I misread the question.

    The second argument of mix.styles() (and mix.scripts()) refers to the output. But it would take a third argument, refering to the base path, so this is the one that you should change, like so:

    elixir(function(mix) {
        mix.styles([
            'bootstrap.min.css',
            'font-awesome.css',
            'animate.css',
            'style.css'
        ], "path/to/output.css", "public/frontend/css");
    });
    

    If you want, you can change the base path in the configs, like stated above:


    Create a elixir.json file at the root of your project and then put the following on it:

    {
        "assetsDir": "public/frontend/"
    }
    

    And you should be good to go.

    Just to provide more information, whenever you need to override a default config, do it in this file. The default configs are:

    var config = {
        production: !! util.env.production,
        srcDir: 'app',
        assetsDir: 'resources/assets/',
        cssOutput: 'public/css',
        jsOutput: 'public/js',
        sourcemaps: ! util.env.production,
        bowerDir: 'vendor/bower_components',
        tasks: [],
        watchers: { default: {} },
        duplicate: [],
        concatenate: { css: [], js: [] },
        compile: {}
    };
    

    from node_modules/laravel-elixir/Config.js.