Skip to content

Commit ea88b78

Browse files
authored
Merge pull request #23 from linagora/temp/rollup
Temp/rollup -> parial-conf
2 parents 1c65e6f + cce220e commit ea88b78

File tree

8 files changed

+13663
-9796
lines changed

8 files changed

+13663
-9796
lines changed

Diff for: package-lock.json

+13,536-9,782
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+14
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,25 @@
6464
]
6565
},
6666
"devDependencies": {
67+
"@rollup/plugin-babel": "^6.0.4",
68+
"@rollup/plugin-commonjs": "^28.0.2",
69+
"@rollup/plugin-html": "^2.0.0",
70+
"@rollup/plugin-image": "^3.0.3",
71+
"@rollup/plugin-inject": "^5.0.5",
72+
"@rollup/plugin-json": "^6.1.0",
73+
"@rollup/plugin-node-resolve": "^16.0.0",
74+
"@rollup/plugin-replace": "^6.0.2",
75+
"@rollup/plugin-typescript": "^12.1.2",
76+
"@svgr/rollup": "^8.1.0",
6777
"@types/redux-mock-store": "^1.0.6",
6878
"http-proxy-middleware": "^3.0.3",
6979
"jest-environment-jsdom": "^29.7.0",
7080
"jest-preview": "^0.3.1",
81+
"postcss-modules": "^6.0.1",
82+
"postcss-preset-env": "^10.1.3",
7183
"react-scripts": "5.0.1",
84+
"rollup-plugin-postcss": "^4.0.2",
85+
"rollup-plugin-terser": "^7.0.2",
7286
"ts-jest": "^29.1.2",
7387
"ts-node": "^10.9.2",
7488
"use-resize-observer": "^9.1.0"

Diff for: rollup.config.js

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/**
2+
* rollup configuration file that reproduce `react-scripts build`
3+
*
4+
* @copyright Yadd <[email protected]>
5+
* license MIT
6+
*/
7+
import babel from "@rollup/plugin-babel";
8+
import commonjs from "@rollup/plugin-commonjs";
9+
import html from "@rollup/plugin-html";
10+
import image from "@rollup/plugin-image";
11+
import inject from "@rollup/plugin-inject";
12+
import json from "@rollup/plugin-json";
13+
import { nodeResolve } from "@rollup/plugin-node-resolve";
14+
import replace from "@rollup/plugin-replace";
15+
import svgr from "@svgr/rollup";
16+
import postcssModules from "postcss-modules";
17+
import postcssPresetEnv from "postcss-preset-env";
18+
import postcss from "rollup-plugin-postcss";
19+
import typescript from "@rollup/plugin-typescript";
20+
import { terser } from "rollup-plugin-terser";
21+
22+
export default {
23+
input: ["src/index.tsx"],
24+
output: {
25+
dir: "dist",
26+
format: "iife",
27+
sourcemap: true,
28+
entryFileNames: "[name]-[hash].js",
29+
inlineDynamicImports: true,
30+
},
31+
plugins: [
32+
svgr(),
33+
image(),
34+
nodeResolve({
35+
browser: true,
36+
extensions: [".js", ".ts", ".jsx", ".tsx"],
37+
}),
38+
babel({
39+
presets: ["@babel/env", "@babel/preset-react"],
40+
plugins: ["@babel/plugin-transform-react-jsx"],
41+
babelHelpers: "bundled",
42+
}),
43+
json(),
44+
replace({
45+
"process.env.NODE_ENV":
46+
process.env.NODE_ENV === "development"
47+
? JSON.stringify("development")
48+
: JSON.stringify("production"),
49+
preventAssignment: true,
50+
"process.env.REACT_APP_HTMLNAME": '""',
51+
}),
52+
typescript({
53+
tsconfig: "./tsconfig.build.json",
54+
declaration: true,
55+
declarationDir: "dist",
56+
}),
57+
postcss({
58+
plugins: [
59+
postcssModules({
60+
generateScopedName: "[local]",
61+
}),
62+
postcssPresetEnv({
63+
stage: 0,
64+
}),
65+
],
66+
}),
67+
commonjs(),
68+
inject({
69+
React: "react",
70+
}),
71+
html({
72+
fileName: "index.html",
73+
title: "React app built with rollup",
74+
template: ({ attributes, bundle, files, publicPath, title }) => {
75+
let scripts = "";
76+
files.js.forEach((bundle) => {
77+
scripts += `<script src="${bundle.fileName}"></script>`;
78+
});
79+
return `<!DOCTYPE html>
80+
<html ${JSON.stringify(attributes)}>
81+
<head>
82+
<title>${title}</title>
83+
</head>
84+
<body>
85+
<div id="root" />
86+
${scripts}
87+
</body>
88+
</html>`;
89+
},
90+
}),
91+
// terser(),
92+
]
93+
};

Diff for: src/App.tsx

+1-7
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ function App({ htmlName }: { htmlName?: string }) {
1818
<Suspense fallback="loading">
1919
<Router history={history}>
2020
<Navbar partial={partial} />
21-
<Routes>
22-
<Route
23-
path={htmlName ? htmlName : "index.html"}
24-
element={
25-
partial ? (
21+
{ partial ? (
2622
<PartialConfiguration
2723
location={{
2824
type: infos ? infos[0] : "",
@@ -48,8 +44,6 @@ function App({ htmlName }: { htmlName?: string }) {
4844
/>
4945
)
5046
}
51-
/>
52-
</Routes>
5347
</Router>
5448
</Suspense>
5549
);

Diff for: src/components/Navbar.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { push } from "redux-first-history";
1616
import { useAppDispatch } from "../app/hooks";
1717
import i18n from "../i18n";
1818
import "./NavBar.css";
19+
import logo from "../static/llng-logo-32.png";
1920

2021
function Navbar({ partial }: { partial?: number }) {
2122
const { t } = useTranslation();
@@ -30,7 +31,7 @@ function Navbar({ partial }: { partial?: number }) {
3031
<Toolbar>
3132
<Typography>
3233
<img
33-
src={require("../static/llng-logo-32.png")}
34+
src={logo}
3435
alt="LemonLogo"
3536
style={{ backgroundColor: "white" }}
3637
/>

Diff for: src/dashboards/HomePage.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import { exportData } from "../utils/exportData";
1919
import { handleChangeFile } from "../utils/readFiles";
2020
import { llngConfig } from "../utils/types";
2121
import "./HomePage.css";
22+
import logo from "./../static/logo_llng_400px.png";
23+
2224
export function HomePage() {
2325
const [openSavePopup, setOpenSavePopup] = useState(false);
2426
const config = useAppSelector((state) => state.config);
@@ -58,7 +60,7 @@ export function HomePage() {
5860
<div>
5961
<img
6062
className="logo"
61-
src={require("./../static/logo_llng_400px.png")}
63+
src={logo}
6264
alt="logo"
6365
/>
6466
</div>

Diff for: src/setupProxy.js

-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
const { createProxyMiddleware } = require("http-proxy-middleware");
22

3-
const rewriteFn = function (path, req) {
4-
return path;
5-
};
6-
const target = "http://manager.example.com:19876";
7-
83
module.exports = function (app) {
94
app.use(
105
"/confs",

Diff for: tsconfig.build.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"exclude": [
4+
"node_modules",
5+
"build",
6+
"dist",
7+
"scripts",
8+
"acceptance-tests",
9+
"webpack",
10+
"jest",
11+
"__test__"
12+
]
13+
}
14+

0 commit comments

Comments
 (0)