Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ charset = utf-8
[*.properties]
charset = latin1

[*.{js, jsx, json, yaml, yml, babelrc}]
[*.{ts, tsx, js, jsx, json, yaml, yml, babelrc}]
indent_size = 2
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@ node_modules

# Webpack build output
src/main/webapp/js

npm-debug.log

# node binaries from frontend-maven-plugin
node/
188 changes: 186 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
"@types/react": "^16.9.35",
"@types/react-dom": "^16.9.8",
"babel-loader": "^8.1.0",
"css-loader": "^3.5.3",
"source-map-loader": "^0.2.4",
"style-loader": "^1.2.1",
"ts-loader": "^7.0.5",
"typescript": "^3.9.3",
"webpack": "^4.43.0",
Expand Down
3 changes: 0 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<configuration>
<workingDirectory>src/main/frontend</workingDirectory>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
3 changes: 0 additions & 3 deletions src/main/frontend/.gitignore

This file was deleted.

2 changes: 2 additions & 0 deletions src/main/frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as React from 'react';

import './css/App.css';

class App extends React.Component<{}, {}> {
render() {
return (
Expand Down
3 changes: 3 additions & 0 deletions src/main/frontend/src/css/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
h1 {
color: blue;
}
2 changes: 2 additions & 0 deletions src/main/frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom';

import App from './App';
import { resetEnvironment } from './resetEnvironment';

resetEnvironment();
const root = document.getElementById('root');
ReactDOM.render(<App/>, root);
1 change: 1 addition & 0 deletions src/main/frontend/src/resetEnvironment.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export function resetEnvironment(): void;
14 changes: 14 additions & 0 deletions src/main/frontend/src/resetEnvironment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Reset JS environment set up by prototype.js to not interfere with
* out react components.
*
* @see https://github.com/jenkinsci/jenkins/blob/75468da366c1d257a51655dcbe952d55b8aeeb9c/war/src/main/js/util/jenkins.js#L22
*/
export function resetEnvironment() {
if (Array.prototype.toJSON) {
delete Array.prototype.toJSON;
delete Object.prototype.toJSON;
delete Hash.prototype.toJSON;
delete String.prototype.toJSON;
}
}
6 changes: 5 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ module.exports = {
test: /\.js$/,
enforce: 'pre',
loader: 'source-map-loader',
}
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
]
},
resolve: {
Expand Down