-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathwebpack.config.js
More file actions
111 lines (105 loc) · 3.23 KB
/
Copy pathwebpack.config.js
File metadata and controls
111 lines (105 loc) · 3.23 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
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 TerserPlugin = require('terser-webpack-plugin');
module.exports = (env) => {
const baseConfig = {
mode: env.production ? 'production' : 'development',
watch: env.watch === 'true' || false,
entry: {
ktui: './src/legacy.ts',
// '../index': './src/index.ts',
// 'ktui.data': './src/helpers/data.ts',
// 'ktui.dom': './src/helpers/dom.ts',
// 'ktui.event-handler': './src/helpers/event-handler.ts',
// 'ktui.utils': './src/helpers/utils.ts',
// 'ktui.accordion': './src/components/accordion/index.ts',
// 'ktui.collapse': './src/components/collapse/index.ts',
// 'ktui.datatable': './src/components/datatable/index.ts',
// 'ktui.dismiss': './src/components/dismiss/index.ts',
// 'ktui.drawer': './src/components/drawer/index.ts',
// 'ktui.dropdown': './src/components/dropdown/index.ts',
// 'ktui.image-input': './src/components/image-input/index.ts',
// 'ktui.menu': './src/components/menu/index.ts',
// 'ktui.modal': './src/components/modal/index.ts',
// 'ktui.reparent': './src/components/reparent/index.ts',
// 'ktui.scrollable': './src/components/scrollable/index.ts',
// 'ktui.scrollspy': './src/components/scrollspy/index.ts',
// 'ktui.scrollto': './src/components/scrollto/index.ts',
// 'ktui.stepper': './src/components/stepper/index.ts',
// 'ktui.sticky': './src/components/sticky/index.ts',
// 'ktui.tabs': './src/components/tabs/index.ts',
// 'ktui.theme': './src/components/theme/index.ts',
// 'ktui.toggle': './src/components/toggle/index.ts',
// 'ktui.toggle-password': './src/components/toggle-password/index.ts',
// 'ktui.tooltip': './src/components/tooltip/index.ts',
},
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
use: ['source-map-loader'],
},
{
test: /\.ts$/,
exclude: [
/node_modules/,
/__tests__/,
/\.test\.ts$/,
/\.spec\.ts$/,
],
use: [{ loader: 'ts-loader' }],
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.jsx'],
},
plugins: [],
target: ['web', 'es5'],
optimization: {
minimize: env.production,
minimizer: [
new TerserPlugin({
terserOptions: {
format: {
comments: false,
},
},
extractComments: false,
}),
],
},
};
const normalConfig = {
...baseConfig,
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
library: { type: 'umd' },
clean: { keep: /styles\.css$/ },
},
devtool: false, // Disable sourcemaps for normal JS files
optimization: {
...baseConfig.optimization,
minimize: false, // Disable minimization for normal JS files
},
plugins: [...baseConfig.plugins],
};
const minifiedConfig = {
...baseConfig,
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].min.js',
sourceMapFilename: '[name].min.js.map',
library: { type: 'umd' },
// Keep ktui.js (from normalConfig) and styles.css so both builds coexist
clean: { keep: /(?:styles\.css|ktui\.js)$/ },
},
devtool: 'source-map', // Enable sourcemaps for minified JS files
optimization: {
...baseConfig.optimization,
minimize: true, // Enable minimization for minified JS files
},
};
return [normalConfig, minifiedConfig];
};