text: const HtmlWebpackPlugin = require('html-webpack-plugin');
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  const VueLoaderPlugin = require('vue-loader/lib/plugin');
  const path = require('path');
  const webpack = require('webpack');
  const { CleanWebpackPlugin } = require('clean-webpack-plugin');
  const merge = require('webpack-merge');
  
  const TARGET = process.env.npm_lifecycle_event;
  
  const strategy = {
    'module.rules.use': 'prepend',
  };
  
  const common = {
    entry: './src/main.js',
    output: {
      path: path.resolve(__dirname, 'dist'),
      filename: 'bundle.js',
    },
    plugins: [
      new webpack.HotModuleReplacementPlugin(),
      new VueLoaderPlugin(),
      new HtmlWebpackPlugin({
        template: './src/views/index.html',
        filename: 'index.html',
      }),
    ],
    module: {
      rules: [
        {
          test: /\.vue$/,
          loader: 'vue-loader',
        },
        {
          test: /\.css$/,
          use: [
            {
              loader: 'css-loader',
              options: { importLoaders: 1 },
            },
            'postcss-loader',
          ],
        },
      ],
    },
    resolve: {
      alias: {
        vue$: 'vue/dist/vue.esm.js',
      },
    },
  };
  
  const dev = {
    mode: 'development',
    devtool: 'cheap-module-eval-source-map',
    module: {
      rules: [
        {
          test: /\.css$/,
          use: [
            'vue-style-loader',
          ],
        },
      ],
    },
    devServer: {
      historyApiFallback: true,
      hot: true,
      open: true,
      openPage: '',
      port: 8080,
      watchContentBase: true,
    },
  };
  
  const prod = {
    mode: 'production',
    plugins: [
      new CleanWebpackPlugin(),
      new MiniCssExtractPlugin({
        filename: 'style.css',
      }),
    ],
    module: {
      rules: [
        {
          test: /\.css$/,
          use: [
            MiniCssExtractPlugin.loader,
          ],
        },
      ],
    },
  };
  
  module.exports = merge.smartStrategy(strategy)(common, {
    dev,
    prod,
  }[TARGET]);
  