---
# System prepended metadata

title: '[laravel]laravel-mix相關筆記'
tags: [laravel-mix, laravel]

---

# [laravel]laravel-mix相關筆記

###### tags: `laravel`,`laravel-mix`

## 複製node_modules的檔案到public資料夾

webpack.mix.js
```javascript=
mix.copyDirectory('node_modules/admin-lte/plugins/datatables', 'public/admin/plugins/datatables');
mix.copyDirectory('node_modules/admin-lte/plugins/datatables-bs4', 'public/admin/plugins/datatables-bs4');
```


## 在前端元件中使用絕對路徑(設定mix.webpack.config)
https://laravel.com/docs/6.x/mix#custom-webpack-configuration

node_modules\laravel-mix\setup\webpack.config.js
>官網中有提到可將此檔案copy至專案根目錄,
>並將pcakage.json的config參數路徑指向該檔.


```javascript=
mix.webpackConfig({
 resolve:{
  extensions:['.js','.vue'],
   alias:{
     '@':__dirname+'/resources'
   }
 }

})
```


>在副檔名為.js及.vue的檔案中,若路徑中有"@",
>則會被取代為專案根目錄/resources
>
>ex:
>require('@/js/bootstrap');
>等同於
>require('專案根目錄/resources/js/bootstrap');



