aboutsummaryrefslogtreecommitdiff
path: root/webpack.config.js
blob: 4a49486686d191b52b96e69f227b63be939d807e (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
const path = require('path');
const webpack = require('webpack');

const configWebWorker = {
  entry: {"cryptoWorker": "./src/cryptoWorker.ts"},
  target: "webworker",
  output: {
    filename: '[name]-bundle.js',
    chunkFilename: "[id].chunk.js",
    path: path.resolve(__dirname, "dist")
  },
  module: {
    noParse: /taler-emscripten-lib/,
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'ts-loader',
        exclude: /node_modules/,
        exclude: /taler-emscripten-lib/,
      }
    ]
  },
  externals: {
    // A big hack to load taler-emscripten-lib from the environment,
    // because we exclude it from the bundle.
    "./emscripten/taler-emscripten-lib": "(self.TalerEmscriptenLib = {}, importScripts('/src/emscripten/taler-emscripten-lib.js'), TalerEmscriptenLib)",
  },
  resolve: {
    modules: [path.resolve(__dirname, "./"), "node_modules"],
    extensions: [".tsx", ".ts", ".js"]
  },
  devtool: "source-map",
}

const configContentScript = {
  entry: {"contentScript": "./src/content_scripts/notify.ts"},
  output: {
    filename: '[name]-bundle.js',
    chunkFilename: "[id].chunk.js",
    path: path.resolve(__dirname, "dist")
  },
  module: {
    noParse: /taler-emscripten-lib/,
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'ts-loader',
        exclude: /node_modules/,
      }
    ]
  },
  resolve: {
    modules: [path.resolve(__dirname, "./"), "node_modules"],
    extensions: [".tsx", ".ts", ".js"]
  },
  devtool: "source-map",
}

const configBackground = {
  entry: {"background": "./src/background/background.ts"},
  output: {
    filename: '[name]-bundle.js',
    chunkFilename: "[id].chunk.js",
    path: path.resolve(__dirname, "dist")
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'ts-loader',
        exclude: /node_modules/,
      }
    ]
  },
  externals: /taler-emscripten-lib/,
  resolve: {
    modules: [path.resolve(__dirname, "./"), "node_modules"],
    extensions: [".tsx", ".ts", ".js"]
  },
  devtool: "source-map",
}


const configExtensionPages = {
  entry: {
    "add-auditor": "./src/pages/add-auditor.tsx",
    "auditors": "./src/pages/auditors.tsx",
    "confirm-contract": "./src/pages/confirm-contract.tsx",
    "confirm-create-reserve": "./src/pages/confirm-create-reserve.tsx",
    "error": "./src/pages/error.tsx",
    "logs": "./src/pages/logs.tsx",
    "popup": "./src/pages/popup.tsx",
    "show-db": "./src/pages/show-db.ts",
    "tree": "./src/pages/tree.tsx",
  },
  output: {
    filename: '[name]-bundle.js',
    chunkFilename: "[id].chunk.js",
    path: path.resolve(__dirname, "dist")
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'ts-loader',
        exclude: /node_modules/,
      }
    ]
  },
  resolve: {
    modules: [path.resolve(__dirname, "./"), "node_modules"],
    extensions: [".tsx", ".ts", ".js"]
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin({
      name: "page-common",
      minChunks: 2,
    }),
  ],
  devtool: "source-map",
}


module.exports = [configBackground, configWebWorker, configContentScript, configExtensionPages];