Alias

A Laravel Mix extension for Webpack alias support.
latest v1.0.1 - released
maximvanhove
123 downloads last week
MIT license
2 versions

Laravel Mix Alias

Add aliases to your source files.

Installation

npm install laravel-mix-alias --save

or

yarn add laravel-mix-alias

Usage

Your webpack.mix.js could look like this:

const mix = require('laravel-mix');
require('laravel-mix-alias');

mix.alias({
    '@': '/resources/assets/js',
    '~': '/resources/assets/sass',
});

or add them one by one

const mix = require('laravel-mix');
require('laravel-mix-alias');

mix.alias('@', '/resources/assets/js');
mix.alias('~', '/resources/assets/sass');

Now you can import sass files from the path you specified

@import "~/variables";

Or import scripts from the path you specified

import '@/script.js';

Author

Maxim Vanhove Web developer at Starring Jane

Twitter Follow