-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
59 lines (51 loc) · 1.74 KB
/
webpack.config.js
File metadata and controls
59 lines (51 loc) · 1.74 KB
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
// webpack.config.js
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
// Use 'development' for easier debugging, change to 'production' for release
mode: 'development',
// Disables eval() for CSP compliance in Chrome extensions
devtool: 'cheap-module-source-map',
// Define the entry points for our extension's scripts
entry: {
background: path.resolve(__dirname, 'src', 'background.ts'),
content: path.resolve(__dirname, 'src', 'content.ts'),
sidebar: path.resolve(__dirname, 'src', 'sidebar', 'index.tsx'),
options: path.resolve(__dirname, 'src', 'options', 'index.tsx'),
},
// Define where the compiled files will be placed
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js', // [name] will be replaced by the entry point key
// This is the critical fix for Edge on Android.
// It tells webpack how to name dynamically imported chunks
// without the leading underscore that Edge blocks.
chunkFilename: 'chunks/[name].[id].chunk.js',
clean: true, // Clean the dist folder before each build
},
// Define how to handle different file types
module: {
rules: [
{
// Use ts-loader for all .ts and .tsx files
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
// Define how to resolve module imports
resolve: {
// Automatically resolve these file extensions
extensions: ['.tsx', '.ts', '.js'],
},
// Use plugins to copy static files to the output directory
plugins: [
new CopyPlugin({
patterns: [
// Copy all files from the 'public' directory to the root of 'dist'
{ from: 'public', to: '.' },
],
}),
],
};