-
Notifications
You must be signed in to change notification settings - Fork 84
/
webpack.config.js
85 lines (82 loc) · 3.6 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
const defaultConfig = require('@wordpress/scripts/config/webpack.config');
const DependencyExtractionWebpackPlugin = require('@wordpress/dependency-extraction-webpack-plugin');
const StyleOnlyEntryPlugin = require('./src/config/style-only-entry-plugin');
const EXTERNAL_NAME = 'kadence';
const HANDLE_NAME = 'kadence';
const PROJECT_NAMESPACE = '@kadence/';
function camelCaseDash(string) {
return string.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
}
module.exports = {
...defaultConfig,
entry: {
icons: './src/packages/icons/src/index.js',
components: './src/packages/components/src/index.js',
helpers: './src/packages/helpers/src/index.js',
'blocks-navigation': './src/blocks/navigation/index.js',
'blocks-navigation-link': './src/blocks/navigation-link/index.js',
'blocks-header': './src/blocks/header/index.js',
'blocks-googlemaps': './src/blocks/googlemaps/block.js',
'blocks-lottie': './src/blocks/lottie/index.js',
'blocks-image': './src/blocks/image/index.js',
'blocks-spacer': './src/blocks/spacer/index.js',
'blocks-advancedbtn': './src/blocks/advancedbtn/block.js',
'blocks-singlebtn': './src/blocks/singlebtn/block.js',
'blocks-countup': './src/blocks/countup/block.js',
'blocks-rowlayout': './src/blocks/rowlayout/index.js',
'blocks-identity': './src/blocks/identity/index.js',
'blocks-column': './src/blocks/column/index.js',
'blocks-advancedheading': './src/blocks/advancedheading/block.js',
'blocks-icon': './src/blocks/icon/block.js',
'blocks-single-icon': './src/blocks/single-icon/block.js',
'blocks-tabs': './src/blocks/tabs/block.js',
'blocks-infobox': './src/blocks/infobox/block.js',
'blocks-accordion': './src/blocks/accordion/block.js',
'blocks-iconlist': './src/blocks/iconlist/block.js',
'blocks-advancedgallery': './src/blocks/advancedgallery/block.js',
'blocks-form': './src/blocks/form/block.js',
'blocks-tableofcontents': './src/blocks/tableofcontents/index.js',
'blocks-posts': './src/blocks/posts/block.js',
'blocks-search': './src/blocks/search/index.js',
'blocks-show-more': './src/blocks/show-more/index.js',
'blocks-countdown': './src/blocks/countdown/block.js',
'blocks-testimonial': './src/blocks/testimonial/block.js',
'blocks-testimonials': './src/blocks/testimonials/block.js',
'blocks-advanced-form': './src/blocks/advanced-form/index.js',
'blocks-progress-bar': './src/blocks/progress-bar/index.js',
'blocks-table': './src/blocks/table/index.js',
'plugin-kadence-control': './src/plugin.js',
'early-filters': './src/early-filters.js',
'extension-kadence-base': './src/extension/kadence-base/index.js',
'extension-stores': './src/extension/stores/index.js',
'extension-block-css': './src/extension/block-css/index.js',
'extension-image-picker': './src/extension/image-picker/index.js',
'admin-kadence-home': './src/home.js',
'header-visual-builder': './src/header-visual-builder.js',
},
output: {
...defaultConfig.output,
path: __dirname + '/dist/',
library: ['kadence', '[name]'],
libraryTarget: 'this',
},
plugins: [
new StyleOnlyEntryPlugin(),
...defaultConfig.plugins.filter((plugin) => plugin.constructor.name !== 'DependencyExtractionWebpackPlugin'),
new DependencyExtractionWebpackPlugin({
requestToExternal(request) {
if (request.endsWith('.css')) {
return false;
}
if (request.startsWith(PROJECT_NAMESPACE)) {
return [EXTERNAL_NAME, camelCaseDash(request.substring(PROJECT_NAMESPACE.length))];
}
},
requestToHandle(request) {
if (request.startsWith(PROJECT_NAMESPACE)) {
return `${HANDLE_NAME}-${request.substring(PROJECT_NAMESPACE.length)}`;
}
},
}),
],
};