summaryrefslogtreecommitdiff
path: root/webpack.config.js
blob: 1ab2401c776f0b1d799c4ef3eb849579f2f1680f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { VueLoaderPlugin } = require('vue-loader');

const isProduction = process.env.NODE_ENV === 'production';

// main config
const config = {
  mode: isProduction ? 'production' : 'development',
  devtool: isProduction ? false : 'source-map',

  entry: {
    index: './app/src/index.js',
  },

  output: {
    path: path.resolve(__dirname, 'app/build'),
    filename: '[name].js',
  },

  resolve: {
    extensions: ['.js', '.vue'],

    alias: {
      '~': path.join(__dirname, 'app/src'),
    },
  },

  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        options: {
          presets: [
            ['@babel/preset-env', {
              targets: {
                browsers: ['> 1%', 'last 2 versions'],
              },
            }],
          ],
          plugins: [
            '@babel/plugin-transform-runtime',
          ],
        },
        exclude: path.resolve(__dirname, 'node_modules'),
      },
      {
        test: /\.s?css$/,
        use: [
          { loader: MiniCssExtractPlugin.loader },
          { loader: 'css-loader' },
          { loader: 'sass-loader' },
        ],
      },
      {
        test: /\.(jpg|png)$/,
        loader: 'url-loader',
        options: {
          limit: 8192,
          outputPath: 'assets/img',
          esModule: false,
        },
      },
    ],
  },

  plugins: [
    new webpack.DefinePlugin({
      __VUE_OPTIONS_API__: true,
      __VUE_PROD_DEVTOOLS__: false,
    }),
    new webpack.ExternalsPlugin('commonjs', ['electron']),
    new MiniCssExtractPlugin(),
    new VueLoaderPlugin(),
  ],

  target: 'electron-renderer',
};

module.exports = config;