-
Notifications
You must be signed in to change notification settings - Fork 745
/
webpack.config.js
106 lines (105 loc) · 3.29 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
/* eslint-disable @typescript-eslint/no-var-requires */
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const { SourceMapDevToolPlugin } = require('webpack');
const path = require('path');
module.exports = {
entry: {
flowbite: path.resolve(__dirname, 'src/index.umd.ts'),
'flowbite.min': path.resolve(__dirname, 'src/index.umd.ts'),
'flowbite.turbo': path.resolve(__dirname, 'src/index.turbo.ts'),
'flowbite.turbo.min': path.resolve(__dirname, 'src/index.turbo.ts'),
'flowbite.phoenix': path.resolve(__dirname, 'src/index.phoenix.ts'),
'flowbite.phoenix.min': path.resolve(__dirname, 'src/index.phoenix.ts'),
docs: path.resolve(__dirname, 'src/docs.js'),
},
devtool: 'inline-source-map',
output: {
filename: '[name].js',
libraryTarget: 'umd',
library: 'Flowbite',
umdNamedDefine: true,
path: path.resolve(__dirname, 'static/'),
},
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
use: ['source-map-loader'],
},
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
],
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
outputPath: 'static/images/',
},
},
{
test: /\.(ttf|eot|svg|gif|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [
{
loader: 'file-loader',
},
],
},
{
test: /\.ts$/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
],
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.jsx', '.css'],
},
plugins: [
new MiniCssExtractPlugin(),
new SourceMapDevToolPlugin({
filename: '[file].map',
}),
],
optimization: {
minimize: true,
minimizer: [
// For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
// `...`,
new CssMinimizerPlugin(),
new TerserPlugin({
include: /\.min\.(css|js)$/,
extractComments: false,
terserOptions: {
format: {
comments: false,
},
},
}),
],
},
target: ['web', 'es5'],
};