-
-
Notifications
You must be signed in to change notification settings - Fork 241
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
331 lines (314 loc) · 10.1 KB
/
rollup.config.mjs
File metadata and controls
331 lines (314 loc) · 10.1 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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
import fs from 'fs';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import terser from '@rollup/plugin-terser';
import postcss from 'rollup-plugin-postcss';
import serve from 'rollup-plugin-serve';
import livereload from 'rollup-plugin-livereload';
import autoprefixer from 'autoprefixer';
import cssnano from 'cssnano';
const isDev = process.env.ROLLUP_WATCH;
// Banner for output files
const banner = `/*!
* jQuery SmartWizard v7.0.2
* A modern and accessible step wizard plugin for jQuery
* http://www.techlaboratory.net/jquery-smartwizard
*
* Created by Dipu Raj (https://github.com/techlab)
*
* Licensed under the terms of the MIT License - Free for personal and open-source projects.
* For commercial use, please purchase a commercial license: https://techlaboratory.net/jquery-smartwizard#license
*/`;
// ============================================================================
// JavaScript Build Configurations
// ============================================================================
const outputFileName = 'jquery.smartWizard';
// Main JS build (UMD, ESM, CJS) - non-minified
const jsConfig = {
input: 'src/index.ts',
external: ['jquery'],
output: [
{
file: `dist/js/${outputFileName}.js`,
format: 'umd',
name: 'smartWizard',
banner,
sourcemap: true,
globals: {
jquery: 'jQuery'
},
exports: 'named'
},
{
file: `dist/js/${outputFileName}.esm.js`,
format: 'es',
banner,
sourcemap: true
},
{
file: `dist/js/${outputFileName}.cjs.js`,
format: 'cjs',
banner,
sourcemap: true,
exports: 'named'
}
],
plugins: [
resolve(),
commonjs(),
typescript({
tsconfig: './tsconfig.json',
declaration: false,
declarationMap: false
})
]
};
// Minified builds - all formats in one config
const jsMinifiedConfigs = {
input: 'src/index.ts',
external: ['jquery'],
output: [
// UMD format
{
file: `dist/js/${outputFileName}.min.js`,
format: 'umd',
name: 'smartWizard',
banner,
sourcemap: true,
globals: {
jquery: 'jQuery'
},
exports: 'named'
},
// ESM format
{
file: `dist/js/${outputFileName}.esm.min.js`,
format: 'es',
banner,
sourcemap: true
},
// CJS format
{
file: `dist/js/${outputFileName}.cjs.min.js`,
format: 'cjs',
banner,
sourcemap: true,
exports: 'named'
}
],
plugins: [
resolve(),
commonjs(),
typescript({
tsconfig: './tsconfig.json',
declaration: false,
declarationMap: false
}),
terser()
]
};
// ============================================================================
// Theme CSS Build Configurations
// ============================================================================
// Theme files to build
const themeFiles = [
{ name: 'basic', path: 'src/styles/themes/basic.scss' },
{ name: 'arrows', path: 'src/styles/themes/arrows.scss' },
{ name: 'pills', path: 'src/styles/themes/pills.scss' },
{ name: 'glow', path: 'src/styles/themes/glow.scss' },
];
// Create configurations for each theme (non-minified)
const themeConfigs = themeFiles.map(theme => ({
input: `.rollup-cache/theme-entry-${theme.name}.js`,
output: {
file: `dist/css/themes/${theme.name}.css`,
format: 'es',
},
watch: {
exclude: ['dist/**', '.rollup-cache/**'],
},
plugins: [
{
name: 'theme-entry-generator',
buildStart() {
// Create temporary entry file for the theme
const entryContent = `import '../${theme.path}';`;
fs.mkdirSync('.rollup-cache', { recursive: true });
fs.writeFileSync(`.rollup-cache/theme-entry-${theme.name}.js`, entryContent);
},
buildEnd() {
// Clean up temporary entry file
const entryFile = `.rollup-cache/theme-entry-${theme.name}.js`;
if (fs.existsSync(entryFile)) {
fs.unlinkSync(entryFile);
}
}
},
postcss({
extract: true,
sourceMap: true,
minimize: false,
plugins: [autoprefixer()],
use: ['sass'],
}),
],
}));
// Create minified configurations for each theme
const themeMinConfigs = themeFiles.map(theme => ({
input: `.rollup-cache/theme-entry-${theme.name}-min.js`,
output: {
file: `dist/css/themes/${theme.name}.min.css`,
format: 'es',
},
watch: {
exclude: ['dist/**', '.rollup-cache/**'],
},
plugins: [
{
name: 'theme-entry-generator-min',
buildStart() {
// Create temporary entry file for the theme
const entryContent = `import '../${theme.path}';`;
fs.mkdirSync('.rollup-cache', { recursive: true });
fs.writeFileSync(`.rollup-cache/theme-entry-${theme.name}-min.js`, entryContent);
},
buildEnd() {
// Clean up temporary entry file
const entryFile = `.rollup-cache/theme-entry-${theme.name}-min.js`;
if (fs.existsSync(entryFile)) {
fs.unlinkSync(entryFile);
}
}
},
postcss({
extract: true,
sourceMap: true,
minimize: true,
plugins: [autoprefixer(), cssnano()],
use: ['sass'],
}),
],
}));
// ============================================================================
// Main CSS Build Configurations
// ============================================================================
// Main CSS (non-minified)
const cssConfig = {
input: '.rollup-cache/main-entry.js',
output: {
file: 'dist/css/smartwizard.css',
format: 'es',
},
watch: {
exclude: ['dist/**', '.rollup-cache/**'],
},
plugins: [
{
name: 'main-css-entry-generator',
buildStart() {
const entryContent = `import '../src/styles/main.scss';`;
fs.mkdirSync('.rollup-cache', { recursive: true });
fs.writeFileSync('.rollup-cache/main-entry.js', entryContent);
},
buildEnd() {
const entryFile = '.rollup-cache/main-entry.js';
if (fs.existsSync(entryFile)) {
fs.unlinkSync(entryFile);
}
}
},
postcss({
extract: true,
sourceMap: true,
minimize: false,
plugins: [autoprefixer()],
use: ['sass'],
}),
],
};
// Main CSS (minified)
const cssMinConfig = {
input: '.rollup-cache/main-entry-min.js',
output: {
file: 'dist/css/smartwizard.min.css',
format: 'es',
},
watch: {
exclude: ['dist/**', '.rollup-cache/**'],
},
plugins: [
{
name: 'main-css-entry-generator-min',
buildStart() {
const entryContent = `import '../src/styles/main.scss';`;
fs.mkdirSync('.rollup-cache', { recursive: true });
fs.writeFileSync('.rollup-cache/main-entry-min.js', entryContent);
},
buildEnd() {
const entryFile = '.rollup-cache/main-entry-min.js';
if (fs.existsSync(entryFile)) {
fs.unlinkSync(entryFile);
}
}
},
postcss({
extract: true,
sourceMap: true,
minimize: true,
plugins: [autoprefixer(), cssnano()],
use: ['sass'],
}),
],
};
// ============================================================================
// Development Server Configuration
// ============================================================================
const devServerConfig = isDev
? [
{
input: 'src/index.ts',
output: {
file: 'dist/js/jquery.smartWizard.js',
format: 'umd',
name: 'smartWizard',
globals: { jquery: 'jQuery' },
exports: 'named',
sourcemap: false, // Disabled to avoid path resolution issues in dev server
},
external: ['jquery'],
plugins: [
resolve(),
commonjs(),
typescript({
tsconfig: './tsconfig.json',
declaration: false,
declarationMap: false
}),
serve({
open: false,
contentBase: ['.'],
port: 3001,
openPage: 'examples/index.html',
}),
livereload({
watch: ['dist', 'examples'],
verbose: true,
delay: 500, // Add delay to ensure files are written before reload
}),
],
},
]
: [];
// ============================================================================
// Export All Configurations
// ============================================================================
export default [
jsConfig,
jsMinifiedConfigs,
cssConfig,
cssMinConfig,
...themeConfigs,
...themeMinConfigs,
...devServerConfig,
];