webpack.mix.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. const mix = require('laravel-mix')
  2. /*
  3. |--------------------------------------------------------------------------
  4. | Mix Asset Management
  5. |--------------------------------------------------------------------------
  6. |
  7. | Mix provides a clean, fluent API for defining some Webpack build steps
  8. | for your Laravel applications. By default, we are compiling the CSS
  9. | file for the application as well as bundling up all the JS files.
  10. |
  11. */
  12. mix
  13. .js('resources/js/app.js', 'public/js')
  14. .webpackConfig({
  15. resolve: {
  16. alias: {
  17. '@resources': path.resolve(__dirname, 'resources/'),
  18. '@': path.resolve(__dirname, 'resources/js/src/'),
  19. '@themeConfig': path.resolve(__dirname, 'resources/js/themeConfig.js'),
  20. '@core': path.resolve(__dirname, 'resources/js/src/@core'),
  21. '@validations': path.resolve(__dirname, 'resources/js/src/@core/utils/validations/validations.js'),
  22. '@axios': path.resolve(__dirname, 'resources/js/src/libs/axios')
  23. }
  24. },
  25. module: {
  26. rules: [
  27. {
  28. test: /\.s[ac]ss$/i,
  29. use: [
  30. {
  31. loader: 'sass-loader',
  32. options: {
  33. sassOptions: {
  34. includePaths: ['node_modules', 'resources/assets']
  35. }
  36. }
  37. }
  38. ]
  39. },
  40. {
  41. test: /(\.(png|jpe?g|gif|webp)$|^((?!font).)*\.svg$)/,
  42. loaders: {
  43. loader: 'file-loader',
  44. options: {
  45. name: 'images/[path][name].[ext]',
  46. context: '../vuexy-vuejs-bootstrap-vue-template/src/assets/images'
  47. // context: 'frontend/src/assets/images'
  48. }
  49. }
  50. }
  51. ]
  52. }
  53. })
  54. .sass('resources/scss/core.scss', 'public/css')
  55. .options({
  56. postCss: [require('autoprefixer'), require('postcss-rtl')]
  57. })
  58. mix.copy('resources/css/loader.css', 'public/css')
  59. // ------------------------------------------------
  60. // If you are deploying on subdomain/subfolder. Uncomment below code before running 'yarn prod' or 'npm run production' command.
  61. // Please Change below 'publicPath' and 'setResourceRoot' options as per your sub-directory path. We have kept our current live demo options which is deployed in sub-folder.
  62. // ------------------------------------------------
  63. /*
  64. if (mix.inProduction()) {
  65. mix.version()
  66. mix.webpackConfig({
  67. output: {
  68. publicPath: '/demo/vuexy-vuejs-laravel-admin-template/demo-1/',
  69. chunkFilename: 'js/chunks/[name].[chunkhash].js'
  70. }
  71. })
  72. mix.setResourceRoot('/demo/vuexy-vuejs-laravel-admin-template/demo-1/')
  73. }
  74. */
  75. // ------------------------------------------------
  76. // If you are deploying on subdomain/subfolder then comment out below code before running 'yarn prod' or 'npm run production' command.
  77. // ------------------------------------------------
  78. mix.webpackConfig({
  79. output: {
  80. chunkFilename: 'js/chunks/[name].[chunkhash].js'
  81. }
  82. })
  83. /*
  84. |--------------------------------------------------------------------------
  85. | Browsersync Reloading
  86. |--------------------------------------------------------------------------
  87. |
  88. | BrowserSync can automatically monitor your files for changes, and inject your changes into the browser without requiring a manual refresh.
  89. | You may enable support for this by calling the mix.browserSync() method:
  90. | Make Sure to run `php artisan serve` and `yarn watch` command to run Browser Sync functionality
  91. | Refer official documentation for more information: https://laravel.com/docs/9.x/mix#browsersync-reloading
  92. */
  93. mix.browserSync('http://127.0.0.1:8000/')