-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
111 lines (110 loc) · 2.86 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
target: 'web',
entry: {
polly: './src/global/polly.js',
welcome: './src/ui/pages/welcome/index.html',
personas: './src/ui/pages/personas/index.html',
personaDetails: './src/ui/pages/personaDetails/index.html',
personaScript: './src/ui/pages/personaDetails/script.js',
chat: './src/ui/pages/chat/index.html',
},
module: {
rules: [
{
test: /\.html$/,
use: 'html-loader',
},
{
test: /\.(mp3)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
},
},
],
},
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{
test: /\.png$/i, ///\.(png|jpe?g|gif)$/i
type: 'asset/resource',
generator: {
filename: 'assets/image/[name][ext]', // Gera imagens na pasta dist/assets/image/
},
},
{
test: /\.svg$/i,
type: 'asset/resource',
generator: {
filename: 'assets/svg/[name].svg',
},
},
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
},
],
},
devServer: {
static: {
directory: path.join(__dirname, 'dist'),
},
watchFiles: ['src/**/*.html', 'src/**/*.css'],
liveReload: true,
client: {
progress: false,
},
historyApiFallback: {
rewrites: [
{ from: /^\/$/, to: '/welcome.html' },
{ from: /^\/personas$/, to: '/personas.html' },
{ from: /^\/persona-details$/, to: '/personaDetails.html' },
{ from: /^\/chat$/, to: '/chat.html' },
],
},
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].bundle.js',
clean: true,
library: '[name]', // Adicione isso para exportar como uma biblioteca global
libraryTarget: 'umd',
globalObject: 'this',
},
plugins: [
new HtmlWebpackPlugin({
template: './src/ui/pages/welcome/index.html',
filename: 'welcome.html',
chunks: ['welcome'],
}),
new HtmlWebpackPlugin({
template: './src/ui/pages/chat/index.html',
filename: 'chat.html',
chunks: ['chat'],
}),
new HtmlWebpackPlugin({
template: './src/ui/pages/personas/index.html',
filename: 'personas.html',
chunks: ['personas'],
}),
new HtmlWebpackPlugin({
template: './src/ui/pages/personaDetails/index.html',
filename: 'personaDetails.html',
chunks: ['polly', 'personaScript', 'personaDetails'],
}),
new MiniCssExtractPlugin(),
],
};