-
Notifications
You must be signed in to change notification settings - Fork 8
/
web-dev-server.config.js
91 lines (82 loc) · 2.5 KB
/
web-dev-server.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
import { compatPlugin } from './.build/compat-plugin.js';
import { esbuildPlugin } from '@web/dev-server-esbuild';
import { fromRollup } from '@web/dev-server-rollup';
import rollupBabel from '@rollup/plugin-babel';
import rollupCommonJS from '@rollup/plugin-commonjs';
import rollupJSON from '@rollup/plugin-json';
import rollupReplace from '@rollup/plugin-replace';
import rollupTailwindInJs from './.build/rollup-plugin-tailwind-in-js.cjs';
import { storybookPlugin } from '@web/dev-server-storybook';
import tailwindConfig from './tailwind.config.cjs';
const tailwindInJsPlugin = fromRollup(rollupTailwindInJs);
const commonjsPlugin = fromRollup(rollupCommonJS);
const replacePlugin = fromRollup(rollupReplace);
const babelPlugin = fromRollup(rollupBabel.default);
const jsonPlugin = fromRollup(rollupJSON);
export default {
nodeResolve: true,
mimeTypes: {
'**/*.cjs': 'js',
'**/custom-elements.json': 'js',
},
middleware: [
(context, next) => {
const url = context.url;
const prefix = '/src/static';
const staticPaths = ['/translations', '/images', '/logo-light.png', '/logo-dark.png'];
if (staticPaths.some(path => url.startsWith(path))) context.url = `${prefix}${url}`;
return next();
},
],
plugins: [
tailwindInJsPlugin({
config: { ...tailwindConfig, purge: false },
extensions: ['.ts'],
}),
commonjsPlugin({
include: [
'**/check-password-strength/**/*',
'**/email-validator/**/*',
'**/cookie-storage/**/*',
'**/html-entities/**/*',
'**/highlight.js/**/*',
'**/url-pattern/**/*',
'**/traverse/**/*',
'**/consola/**/*',
'**/jsonata/**/*',
'**/uainfer/**/*',
'**/dedent/**/*',
'**/@babel/**/*',
'**/chalk/**/*',
],
exclude: [
'**/@web/**/*',
'**/@open-wc/**/*',
'**/cross-fetch/**/*',
'**/i18next-http-backend/**/*',
],
}),
babelPlugin({
babelHelpers: 'bundled',
plugins: [
[
'babel-plugin-module-resolver',
{
alias: {
'cross-fetch': 'cross-fetch/dist/browser-ponyfill.js',
'consola': 'consola/dist/consola.browser.js',
},
},
],
],
}),
storybookPlugin({ type: 'web-components' }),
replacePlugin({
'process.env.NODE_ENV': '"production"',
'embed.foxy.io': 'embed.foxy.test',
}),
esbuildPlugin({ ts: true }),
compatPlugin(),
jsonPlugin(),
],
};