const path = require('path')

const webpack = require('webpack')
const { VueLoaderPlugin } = require('vue-loader')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const { compact } = require('lodash')

const rootDir = process.cwd()

module.exports = compact([
  new VueLoaderPlugin(),

  new webpack.DefinePlugin({
    'process.env': {
      NODE_ENV: '"production"'
    }
  }),

  new MiniCssExtractPlugin({
    chunkFilename: '[id].[contenthash].css',
  }),

  new CopyWebpackPlugin([
    {
      from: path.resolve(rootDir, './src/css'),
      to: './css',
    },
  ]),
])
