forked from verbb/formie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.mix.js
179 lines (144 loc) · 6.74 KB
/
webpack.mix.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
const mix = require('laravel-mix');
const path = require('path');
// Mix plugins
const autoprefixer = require('autoprefixer');
const eslint = require('laravel-mix-eslint-config');
const polyfill = require('laravel-mix-polyfill');
const imagemin = require('laravel-mix-imagemin');
const assetsPath = './src/web/assets';
const postcssCustomProperties = require('postcss-custom-properties');
// Set the public path
mix.setPublicPath(assetsPath);
//
// Forms
//
// Setup and configure Sass
mix.sass(assetsPath + '/forms/src/scss/style.scss', assetsPath + '/forms/dist/css');
// Setup and configure JS
mix.js(assetsPath + '/forms/src/js/main.js', assetsPath + '/forms/dist/js');
// Directly copy over some folders
mix.copy(assetsPath + '/forms/src/fonts', assetsPath + '/forms/dist/fonts');
//
// Front-End
//
// Setup and configure Sass
mix.sass(assetsPath + '/frontend/src/scss/formie-base.scss', assetsPath + '/frontend/dist/css');
mix.sass(assetsPath + '/frontend/src/scss/formie-theme.scss', assetsPath + '/frontend/dist/css');
mix.sass(assetsPath + '/frontend/src/scss/fields/phone-country.scss', assetsPath + '/frontend/dist/css/fields');
mix.sass(assetsPath + '/frontend/src/scss/fields/tags.scss', assetsPath + '/frontend/dist/css/fields');
// Setup and configure JS
mix.js(assetsPath + '/frontend/src/js/formie.js', assetsPath + '/frontend/dist/js');
mix.js(assetsPath + '/frontend/src/js/fields/file-upload.js', assetsPath + '/frontend/dist/js/fields');
mix.js(assetsPath + '/frontend/src/js/fields/phone-country.js', assetsPath + '/frontend/dist/js/fields');
mix.js(assetsPath + '/frontend/src/js/fields/repeater.js', assetsPath + '/frontend/dist/js/fields');
mix.js(assetsPath + '/frontend/src/js/fields/table.js', assetsPath + '/frontend/dist/js/fields');
mix.js(assetsPath + '/frontend/src/js/fields/tags.js', assetsPath + '/frontend/dist/js/fields');
mix.js(assetsPath + '/frontend/src/js/fields/checkbox-radio.js', assetsPath + '/frontend/dist/js/fields');
mix.js(assetsPath + '/frontend/src/js/fields/text-limit.js', assetsPath + '/frontend/dist/js/fields');
mix.js(assetsPath + '/frontend/src/js/fields/rich-text.js', assetsPath + '/frontend/dist/js/fields');
mix.js(assetsPath + '/frontend/src/js/fields/conditions.js', assetsPath + '/frontend/dist/js/fields');
mix.js(assetsPath + '/frontend/src/js/fields/date-picker.js', assetsPath + '/frontend/dist/js/fields');
mix.js(assetsPath + '/frontend/src/js/fields/hidden.js', assetsPath + '/frontend/dist/js/fields');
mix.js(assetsPath + '/frontend/src/js/fields/summary.js', assetsPath + '/frontend/dist/js/fields');
mix.js(assetsPath + '/frontend/src/js/fields/signature.js', assetsPath + '/frontend/dist/js/fields');
mix.js(assetsPath + '/frontend/src/js/fields/calculations.js', assetsPath + '/frontend/dist/js/fields');
//
// Integrations
//
// Setup and configure JS
mix.js(assetsPath + '/addressproviders/src/js/algolia-places.js', assetsPath + '/addressproviders/dist/js');
mix.js(assetsPath + '/addressproviders/src/js/google-address.js', assetsPath + '/addressproviders/dist/js');
mix.js(assetsPath + '/addressproviders/src/js/address-finder.js', assetsPath + '/addressproviders/dist/js');
mix.js(assetsPath + '/addressproviders/src/js/loqate.js', assetsPath + '/addressproviders/dist/js');
mix.js(assetsPath + '/captchas/src/js/recaptcha-v2-checkbox.js', assetsPath + '/captchas/dist/js');
mix.js(assetsPath + '/captchas/src/js/recaptcha-v2-invisible.js', assetsPath + '/captchas/dist/js');
mix.js(assetsPath + '/captchas/src/js/recaptcha-v3.js', assetsPath + '/captchas/dist/js');
mix.js(assetsPath + '/captchas/src/js/recaptcha-enterprise.js', assetsPath + '/captchas/dist/js');
mix.js(assetsPath + '/captchas/src/js/javascript.js', assetsPath + '/captchas/dist/js');
mix.js(assetsPath + '/captchas/src/js/hcaptcha.js', assetsPath + '/captchas/dist/js');
//
// General CP
//
// Setup and configure JS
mix.js(assetsPath + '/cp/src/js/formie-cp.js', assetsPath + '/cp/dist/js');
mix.js(assetsPath + '/cp/src/js/integration-settings.js', assetsPath + '/cp/dist/js');
// Setup and configure Sass
mix.sass(assetsPath + '/cp/src/scss/formie-cp.scss', assetsPath + '/cp/dist/css');
//
// Widgets
//
// Setup and configure JS
mix.js(assetsPath + '/widgets/src/js/formie-widgets.js', assetsPath + '/widgets/dist/js');
// Setup and configure Sass
mix.sass(assetsPath + '/widgets/src/scss/formie-widgets.scss', assetsPath + '/widgets/dist/css');
// Optimise images and SVGs
mix.imagemin([
{ from: assetsPath + '/forms/src/img', to: 'forms/dist/img' },
{ from: assetsPath + '/addressproviders/src/img', to: 'addressproviders/dist/img' },
{ from: assetsPath + '/captchas/src/img', to: 'captchas/dist/img' },
{ from: assetsPath + '/elements/src/img', to: 'elements/dist/img' },
{ from: assetsPath + '/emailmarketing/src/img', to: 'emailmarketing/dist/img' },
{ from: assetsPath + '/crm/src/img', to: 'crm/dist/img' },
{ from: assetsPath + '/webhooks/src/img', to: 'webhooks/dist/img' },
{ from: assetsPath + '/miscellaneous/src/img', to: 'miscellaneous/dist/img' },
], {}, {
gifsicle: { interlaced: true },
mozjpeg: { progressive: true, arithmetic: false },
optipng: { optimizationLevel: 3 }, // Lower number = speedier/reduced compression
svgo: {
plugins: [
{ convertColors: { currentColor: false } },
{ removeDimensions: false },
{ removeViewBox: false },
{ cleanupIDs: false },
],
},
});
// Setup additional CSS-related options including Tailwind and any other PostCSS items
mix.options({
// Disable processing css urls for speed
processCssUrls: false,
postCss: [
// PostCSS plugins
autoprefixer(),
postcssCustomProperties(),
],
});
// Setup JS-linting
mix.eslint({
exclude: [
'node_modules',
path.resolve(__dirname, assetsPath + '/forms/src/js/vendor'),
],
options: {
fix: true,
cache: false,
},
});
// Setup some aliases
mix.webpackConfig({
resolve: {
alias: {
// Form Utils
'@utils': path.resolve(__dirname, assetsPath + '/forms/src/js/utils'),
// Local vendor modules
'@vuedraggable': path.resolve(__dirname, assetsPath + '/forms/src/js/vendor/vuedraggable'),
'@accessible-tabs': path.resolve(__dirname, assetsPath + '/forms/src/js/vendor/vue-accessible-tabs'),
}
},
externals: {
vue: 'Vue',
}
});
// Always allow versioning of assets
mix.version();
if (mix.inProduction()) {
// Add polyfills
mix.polyfill({
enabled: true,
useBuiltIns: 'usage', // Only add a polyfill when a feature is used
targets: false, // "false" makes the config use .browserslistrc file
corejs: 3,
debug: false, // "true" to check which polyfills are being used
});
}