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({
  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.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');
mix.copy('resources/assets/images/*', 'public/assets/images');

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