-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
112 lines (110 loc) · 3.46 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
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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const fs = require('fs');
module.exports = {
devtool: "source-map",
mode: 'production',
entry: {
preferences: './src/preferences/scripts/preferences.tsx',
plugin_page: './src/plugin_page/scripts/pluginPage.tsx',
content_pages: './src/content_pages/scripts/content_pages.tsx',
},
output: {
path: path.resolve(__dirname, './dist/'),
filename: (pathData) => {
const entryName = pathData.chunk.name;
return `scripts/${entryName}_bundle.js`;
},
},
optimization: {
minimize: false,
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader, // Extract CSS into separate files
'css-loader',
],
},
{
test: /\.html$/,
use: 'html-loader',
},
{
test: /\.ejs$/,
use: [
{
loader: 'ejs-loader',
options: {
esModule: false, // Ensures compatibility with EJS
},
},
],
},
{
test: /\.(png|jpe?g|gif)$/i,
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'images',
publicPath: 'images',
},
},
],
},
resolve: {
alias: {
browser: path.resolve(__dirname, 'src'),
},
extensions: ['.tsx', '.ts', '.js'],
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css', // Separate CSS file per entry
}),
new HtmlWebpackPlugin({
chunks: ['plugin_page'],
template: 'src/plugin_page/index.ejs',
filename: 'plugin_page/index.html',
inject: 'body',
templateParameters: () => {
return {
header: fs.readFileSync(path.resolve(__dirname, 'src/plugin_page/inc/header.html'), 'utf8'),
urlForm: fs.readFileSync(path.resolve(__dirname, 'src/plugin_page/inc/urlForm.html'), 'utf8'),
urlList: fs.readFileSync(path.resolve(__dirname, 'src/plugin_page/inc/urlList.html'), 'utf8'),
groupForm: fs.readFileSync(path.resolve(__dirname, 'src/plugin_page/inc/groupForm.html'), 'utf8'),
footer: fs.readFileSync(path.resolve(__dirname, 'src/plugin_page/inc/footer.html'), 'utf8'),
accountConfig: fs.readFileSync(path.resolve(__dirname, 'src/plugin_page/inc/accountConfig.html'), 'utf8'),
preferences: fs.readFileSync(path.resolve(__dirname, 'src/plugin_page/inc/preferences.html'), 'utf8'),
containers: fs.readFileSync(path.resolve(__dirname, 'src/plugin_page/inc/containers.html'), 'utf8'),
};
},
}),
new HtmlWebpackPlugin({
template: 'src/preferences/index.html',
filename: 'preferences/index.html',
chunks: ['preferences'],
}),
new HtmlWebpackPlugin({
chunks: ['content_pages'],
}),
new CopyWebpackPlugin({
patterns: [
{ from: 'src/manifest.json', to: 'manifest.json' },
{ from: 'src/coloris/coloris.js', to: 'coloris/coloris.js' },
{ from: 'src/coloris/coloris.css', to: 'coloris/coloris.css' },
{ from: 'src/content_pages/css/content_pages.css', to: 'content_pages.css' },
{ from: 'src/icons', to: 'icons' },
],
}),
],
};