Skip to content

Commit 4c37c10

Browse files
authored
@lexical/playground: Moved Vite config to TS and removed code duplication (#5744)
1 parent c4e9dec commit 4c37c10

File tree

5 files changed

+127
-299
lines changed

5 files changed

+127
-299
lines changed

packages/lexical-playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"dev": "vite --host",
77
"build-dev": "vite build",
8-
"build-prod": "vite build --config vite.prod.config.js",
8+
"build-prod": "vite build --config vite.prod.config.ts",
99
"build-vercel": "(cd ../../ && node ./scripts/build.js --prod) && npm run build-prod",
1010
"preview": "vite preview"
1111
},
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
*/
8+
9+
import babel from '@rollup/plugin-babel';
10+
import react from '@vitejs/plugin-react';
11+
import {defineConfig} from 'vite';
12+
import {replaceCodePlugin} from 'vite-plugin-replace';
13+
14+
import moduleResolution from './viteModuleResolution';
15+
16+
// https://vitejs.dev/config/
17+
export default defineConfig({
18+
build: {
19+
outDir: 'build',
20+
rollupOptions: {
21+
input: {
22+
main: new URL('./index.html', import.meta.url).pathname,
23+
split: new URL('./split/index.html', import.meta.url).pathname,
24+
},
25+
},
26+
},
27+
define: {
28+
'process.env.IS_PREACT': process.env.IS_PREACT,
29+
},
30+
plugins: [
31+
replaceCodePlugin({
32+
replacements: [
33+
{
34+
from: /__DEV__/g,
35+
to: 'true',
36+
},
37+
],
38+
}),
39+
babel({
40+
babelHelpers: 'bundled',
41+
babelrc: false,
42+
configFile: false,
43+
exclude: '/**/node_modules/**',
44+
extensions: ['jsx', 'js', 'ts', 'tsx', 'mjs'],
45+
plugins: [
46+
'@babel/plugin-transform-flow-strip-types',
47+
[
48+
require('../../scripts/error-codes/transform-error-messages'),
49+
{
50+
noMinify: true,
51+
},
52+
],
53+
],
54+
presets: ['@babel/preset-react'],
55+
}),
56+
react(),
57+
],
58+
resolve: {
59+
alias: moduleResolution,
60+
},
61+
});

packages/lexical-playground/vite.prod.config.js

Lines changed: 0 additions & 224 deletions
This file was deleted.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
*/
8+
9+
import babel from '@rollup/plugin-babel';
10+
import react from '@vitejs/plugin-react';
11+
import {defineConfig} from 'vite';
12+
import {replaceCodePlugin} from 'vite-plugin-replace';
13+
14+
import moduleResolution from './viteModuleResolution';
15+
16+
// https://vitejs.dev/config/
17+
export default defineConfig({
18+
build: {
19+
commonjsOptions: {include: []},
20+
minify: 'terser',
21+
outDir: 'build',
22+
rollupOptions: {
23+
input: {
24+
main: new URL('./index.html', import.meta.url).pathname,
25+
split: new URL('./split/index.html', import.meta.url).pathname,
26+
},
27+
},
28+
terserOptions: {
29+
compress: {
30+
toplevel: true,
31+
},
32+
},
33+
},
34+
define: {
35+
'process.env.IS_PREACT': process.env.IS_PREACT,
36+
},
37+
plugins: [
38+
replaceCodePlugin({
39+
replacements: [
40+
{
41+
from: /__DEV__/g,
42+
to: 'true',
43+
},
44+
],
45+
}),
46+
babel({
47+
babelHelpers: 'bundled',
48+
babelrc: false,
49+
configFile: false,
50+
exclude: '/**/node_modules/**',
51+
extensions: ['jsx', 'js', 'ts', 'tsx', 'mjs'],
52+
plugins: ['@babel/plugin-transform-flow-strip-types'],
53+
presets: ['@babel/preset-react'],
54+
}),
55+
react(),
56+
],
57+
resolve: {
58+
alias: moduleResolution,
59+
},
60+
});

0 commit comments

Comments
 (0)