Use Laravel Mix in stand alone projects

August 27, 2017
1 min read

This content is over a year old

When reading, please keep its age in mind as the information presented may be out of date with current developments, practices or personal viewpoints.

Install Laravel Mix and Webpack

Using yarn or npm, install both Laravel Mix and Webpack to your project. I will be utilizing yarn in the examples below.

yarn add webpack laravel-mix

Copy the Laravel Mix Configuration

cp -r node_modules/laravel-mix/setup/webpack.mix.js ./

Add Compilation Scripts to Your package.json

"scripts": {
    "dev": "NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "hot": "NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "production": "NODE_ENV=production webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
}

You're now all set! Simply hop in your webpack.mix.js file to configure the files you wish to compile.