summaryrefslogtreecommitdiff
path: root/electron/service/config/main.js
blob: 3083dea0c7fac0c471cf3df014fad81fcb19934f (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
'use strict'

const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin')
const config = require('../project.config')

const resolveClientEnv = require('../utils/resolveClientEnv')
const paths = require('../utils/paths')
const { merge } = require('webpack-merge')
const TerserPlugin = require('terser-webpack-plugin')
const cssWebpackConfig = require('./css')
const terserOptions = require('./terserOptions')
const isProd = process.env.NODE_ENV === 'production'

module.exports = merge(cssWebpackConfig, {
  context: process.cwd(),
    mode: 'production',
  entry: {
    main: './src/main/index.js',
    preload: './src/main/preload.js',
  },
  
  node: {
    __dirname: false,
  },
  
  optimization: {
    minimize: true,
    minimizer: [new TerserPlugin(terserOptions())],
    moduleIds: 'named',
  },
  target: ['electron-main'],

  output: {
    path: paths.resolve(config.outputDir),
    publicPath: config.dev.publicPath,
    filename: '[name].js',
  },

  resolve: {
    alias: {
      '@': paths.resolve('src'),
    },
    extensions: ['.ts', '.tsx', '.js', '.jsx', '.vue', '.json', 'html', 'ejs'],
  },

  plugins: [
    new CaseSensitivePathsPlugin(),
  ],

  module: {
    noParse: /^(vue|vue-router)$/,

    rules: [
      // ts
      {
        test: /\.tsx?$/,
        use: [
          'thread-loader',
          'babel-loader',
          {
            loader: 'ts-loader',
            options: {
              transpileOnly: true,
              appendTsSuffixTo: ['\\.vue$'],
              happyPackMode: true,
            },
          },
        ],
      },
    ],
  },
}
)