Skip to content

Instantly share code, notes, and snippets.

@ilhamdoanggg
Created April 16, 2017 19:00
Show Gist options
  • Save ilhamdoanggg/0794921701e265626f23171afc58df73 to your computer and use it in GitHub Desktop.
Save ilhamdoanggg/0794921701e265626f23171afc58df73 to your computer and use it in GitHub Desktop.
error compile mix
'use strict';
const path = require('path');
const del = require('del');
const {mix} = require('laravel-mix');
const env = require('prop-env');
const basePath = (...fp) => path.join(__dirname, ...fp || '');
const assetPath = (...fp) => basePath('resources/assets', ...fp);
const publicPath = (...fp) => basePath('public', ...fp);
/**
|------------------------------------------------------------------
| Cleanup - Temporary Tool
|------------------------------------------------------------------
|
| Menghapus semua file hasil render atau kompilasi "webpack".
|
*/
del.sync([
publicPath('css/*'),
publicPath('js/*'),
publicPath('images/*'),
publicPath('fonts/*'),
]);
/**
|------------------------------------------------------------------
| Administrator Javascript application
|------------------------------------------------------------------
|
| Kompile Javascript aplikasi untuk "administrator". Hasil render
| atau kompilasi akan terletak pada "public/js/admin/admin.js"
| file yang hanya dikhususkan pada halaman "administrator".
|
*/
mix.js([
assetPath('js/globals.js'),
assetPath('js/admin/visual.js'),
assetPath('js/admin/cpanel.js'),
], 'public/js/admin/admin.js');
/**
|------------------------------------------------------------------
| Public Javascript application
|------------------------------------------------------------------
|
| Compile javascript aplikasi untuk "public" atau "umum". Hasil
| kompilasi akan terletak pada directory "public/js/app.js".
|
*/
mix.js([
assetPath('js/globals.js'),
assetPath('js/visual.js'),
assetPath('js/app.js'),
], 'public/js/app.js');
/**
|------------------------------------------------------------------
| Stylesheet Applications
|------------------------------------------------------------------
|
| Compile stylesheet yang menggunakan "SASS" engine menjadi "CSS"
| agar dapat di akses oleh browser. File "CSS" hasil kompilasi
| berada pada path "public/css" dengan nama file yang sama.
|
*/
mix.sass(assetPath('sass/vendor.scss'), 'public/css');
mix.less('resources/assets/less/app.less', 'public/css');
/**
|------------------------------------------------------------------
| Copy Images Applications
|------------------------------------------------------------------
|
| Melakukan "copy" images dari folder "resources/asssets/images"
| ke folder "public/images" untuk kebutuhan apps "interface".
|
| Untuk "images" yang di "upload" tidak diletakkan pada folder
| tersebut. File yang di "upload" akan terletak pada folder
| "public/storage" yang merupakan "symlinks" dari folder
| "storage/app/public". Lihat "artisan storage:link".
|
*/
mix.copy(assetPath('images'), 'public/images');
/**
|------------------------------------------------------------------
| Global browser variable
|------------------------------------------------------------------
|
| Mendaftarkan "global" variable dari "npm" module. Metode ini
| sama seperti dengan menggunakan "window" yang di tuliskan
| pada file "javascript" applikasi. Baca "docs" release.
|
| Docs: https://github.com/JeffreyWay/laravel-mix/blob/master/docs/autoloading.md
|
*/
mix.autoload({
axios: 'axios',
jquery: ['$', 'jQuery'],
});
/**
|------------------------------------------------------------------
| Webpack Extrack Plugin
|------------------------------------------------------------------
|
| Ekstraksi "node_module" yang di "import" atau "require" dari
| setiap scripts "file" atau "component", kemudian disimpan
| pada file "public/js/vendor.js". Lihat "docs" release.
|
| Docs: https://github.com/JeffreyWay/laravel-mix/blob/master/docs/extract.md
|
*/
mix.extract(['vue', 'vuex', 'jquery', 'axios']);
/**
|------------------------------------------------------------------
| Versioning
|------------------------------------------------------------------
|
| Generate "uniq" nama file hanya untuk release "production".
|
*/
if (process.env.NODE_ENV === 'production') {
mix.version();
}
/**
|------------------------------------------------------------------
| BrowserSync
|------------------------------------------------------------------
|
| Auto refresh "browser" saat melakukan perubahan "script" kode.
|
*/
//mix.browserSync(env('APP_URL'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment