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

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.webpackConfig({
  resolve: {
    alias: {
      // Alias for using source of BootstrapVue
      'bootstrap-vue$': 'bootstrap-vue/src',
      'vue$': 'vue/dist/vue.esm.js' // 'vue/dist/vue.common.js' for webpack 1
    },
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        // Exclude transpiling `node_modules`, except `bootstrap-vue/src`
        exclude: /node_modules\/(?!bootstrap-vue\/src\/)/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env']
          }
        }
      }
    ]
  }
});

mix.setPublicPath('public/assets');
mix.options({processCssUrls: false});

mix.js([
  'resources/assets/js/components/AdminZoznamSekcii/main.js',
], 'public/assets/js/adminZoznamSekciiApp.js')
.version();

mix.js([
  'resources/assets/js/components/VysledokVyhladavania/main.js',
], 'public/assets/js/vyhladavanieApp.js')
.version();

mix.js([
  'resources/assets/js/components/PrehliadacUcebnehoMaterialu/main.js',
], 'public/assets/js/prehliadacUcebnehoMaterialuApp.js')
.version();

mix.js([
  'resources/assets/js/components/TestovaniePouzivatela/main.js',
], 'public/assets/js/testovanieApp.js')
.version();

mix.copy('resources/assets/images', 'public/assets/images');
mix.copy('node_modules/tinymce/tinymce.min.js', 'public/assets/js/tinymce');
mix.copy('node_modules/tinymce/themes', 'public/assets/js/tinymce/themes');
mix.copy('node_modules/tinymce/plugins', 'public/assets/js/tinymce/plugins');
mix.copy('node_modules/tinymce/skins', 'public/assets/js/tinymce/skins');
mix.copy('node_modules/tinymce/icons', 'public/assets/js/tinymce/icons');
mix.copy('resources/assets/js/tinymce/langs', 'public/assets/js/tinymce/langs');

if (mix.inProduction()) {
  mix.version();
}

/*
 /--------------------------------------------------------------------------
 / BACKEND
 /--------------------------------------------------------------------------
 */
