-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
85 lines (83 loc) · 2.51 KB
/
webpack.config.js
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
const path = require('path');
const TransformJson = require('transform-json-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const WorkerPlugin = require("worker-plugin");
const webpack = require('webpack');
const packageInfo = require('./package.json')
// replace accordingly './.env' with the path of your .env file
require('dotenv').config();
module.exports = {
mode: 'development',
entry: {
directory: './src/content/directory.tsx',
"track-watch": './src/content/track-watch.ts',
background: './src/background/background.ts',
'trainer': './src/background/trainer.ts',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.jsx?$/,
exclude: path.resolve(__dirname, 'src'),
enforce: 'pre',
use: 'source-map-loader'
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: 'babel-loader'
},
],
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
fallback:
{
"assert": require.resolve("assert/"),
"crypto": require.resolve("crypto-browserify"),
"buffer": require.resolve("buffer/") ,
"stream": require.resolve("stream-browserify")
},
},
devServer: {
static: './dist',
port: 8080,
hot: true,
watchFiles: ['*'],
},
plugins: [
new webpack.DefinePlugin({
'process.env': JSON.stringify(process.env),
}),
new TransformJson({
source: path.resolve(__dirname, 'src', 'manifest.json'),
filename: 'manifest.json',
object: {
description: packageInfo.description,
version: packageInfo.version
}
}),
new CopyWebpackPlugin({
patterns: [
{from: 'src/static', to: './',},
{from: 'src/images', to: './images',},
{from: 'src/saved-data.json', to: './'}
]
}),
new WorkerPlugin(),
],
// For when 1 HTML page can have multiple entry points
// optimization: {
// runtimeChunk: 'single',
// }
devtool: 'source-map'
};