mirror of
https://github.com/Febbweiss/springboot-react-webpack.git
synced 2026-03-04 22:25:34 +00:00
Generated JS and CSS to the target/classes/static folder
This commit is contained in:
28
pom.xml
28
pom.xml
@@ -171,26 +171,6 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- Resource optimization -->
|
<!-- Resource optimization -->
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-antrun-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>clean</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>run</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<target>
|
|
||||||
<delete dir="${project.basedir}/src/main/resources/static/js/bundle" />
|
|
||||||
<delete dir="${project.basedir}/src/main/resources/static/js/jsx" />
|
|
||||||
<delete dir="${project.basedir}/src/main/resources/static/css/bundle" />
|
|
||||||
<delete dir="${project.basedir}/src/test/resources/static/js/compiled" />
|
|
||||||
</target>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
<executions>
|
<executions>
|
||||||
@@ -231,7 +211,7 @@
|
|||||||
${project.basedir}/src/main/resources/static/js
|
${project.basedir}/src/main/resources/static/js
|
||||||
</sourcePath>
|
</sourcePath>
|
||||||
<targetPath>
|
<targetPath>
|
||||||
${project.basedir}/src/main/resources/static/js/jsx
|
${project.build.directory}/classes/static/js
|
||||||
</targetPath>
|
</targetPath>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
@@ -267,8 +247,8 @@
|
|||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
|
<wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
|
||||||
<cssDestinationFolder>${project.basedir}/src/main/resources/static/css/bundle</cssDestinationFolder>
|
<cssDestinationFolder>${project.build.directory}/classes/static/css</cssDestinationFolder>
|
||||||
<jsDestinationFolder>${project.basedir}/src/main/resources/static/js/bundle</jsDestinationFolder>
|
<jsDestinationFolder>${project.build.directory}/classes/static/js</jsDestinationFolder>
|
||||||
<wroFile>${project.build.directory}/wro/wro.xml</wroFile>
|
<wroFile>${project.build.directory}/wro/wro.xml</wroFile>
|
||||||
<extraConfigFile>${project.basedir}/src/main/wro/wro.properties</extraConfigFile>
|
<extraConfigFile>${project.basedir}/src/main/wro/wro.properties</extraConfigFile>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -316,7 +296,7 @@
|
|||||||
<preloadSource>/webjars/jquery.mockjax.js</preloadSource>
|
<preloadSource>/webjars/jquery.mockjax.js</preloadSource>
|
||||||
<preloadSource>${project.basedir}/src/test/resources/jasmine/config.js</preloadSource>
|
<preloadSource>${project.basedir}/src/test/resources/jasmine/config.js</preloadSource>
|
||||||
</preloadSources>
|
</preloadSources>
|
||||||
<jsSrcDir>${project.basedir}/src/main/resources/static/js</jsSrcDir>
|
<jsSrcDir>${project.build.directory}/classes/static/js</jsSrcDir>
|
||||||
<sourceIncludes>
|
<sourceIncludes>
|
||||||
<include>**/*.js</include>
|
<include>**/*.js</include>
|
||||||
</sourceIncludes>
|
</sourceIncludes>
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
<head lang="en">
|
<head lang="en">
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>Comments channel</title>
|
<title>Comments channel</title>
|
||||||
<link rel="stylesheet" href="/css/bundle/react-bootstrap.css" />
|
<link rel="stylesheet" href="/css/react-bootstrap.css" />
|
||||||
<link rel="stylesheet" href="/css/bundle/comments.css" />
|
<link rel="stylesheet" href="/css/comments.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
<div th:replace="fragments/footer"></div>
|
<div th:replace="fragments/footer"></div>
|
||||||
|
|
||||||
<script src="/js/bundle/react-bootstrap.js"></script>
|
<script src="/js/react-bootstrap.js"></script>
|
||||||
<script src="/js/bundle/comments.js"></script>
|
<script src="/js/comments.js"></script>
|
||||||
<script src="/js/jsx/app.js"></script>
|
<script src="/js/app.js"></script>
|
||||||
<script src="/js/jsx/app.render.js"></script>
|
<script src="/js/app.render.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
.footer {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 60px;
|
|
||||||
background-color: #f5f5f5;
|
|
||||||
}
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var Comment = React.createClass({
|
|
||||||
rawMarkup: function() {
|
|
||||||
var rawMarkup = marked(this.props.children.toString(), {sanitize: true});
|
|
||||||
return { __html: rawMarkup };
|
|
||||||
},
|
|
||||||
render: function() {
|
|
||||||
return (
|
|
||||||
<div className="comment">
|
|
||||||
<h2 className="commentAuthor">
|
|
||||||
{this.props.author}
|
|
||||||
</h2>
|
|
||||||
<span dangerouslySetInnerHTML={this.rawMarkup()} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var CommentForm = React.createClass({
|
|
||||||
getInitialState: function() {
|
|
||||||
return {author: '', text: ''};
|
|
||||||
},
|
|
||||||
handleAuthorChange: function(e) {
|
|
||||||
this.setState({author: e.target.value});
|
|
||||||
},
|
|
||||||
handleTextChange: function(e) {
|
|
||||||
this.setState({text: e.target.value});
|
|
||||||
},
|
|
||||||
handleSubmit: function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var author = this.state.author.trim();
|
|
||||||
var text = this.state.text.trim();
|
|
||||||
if( !text || !author ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.props.onCommentSubmit({author: author, text: text})
|
|
||||||
this.setState({author: '', text: ''});
|
|
||||||
},
|
|
||||||
render: function() {
|
|
||||||
return (
|
|
||||||
<form className="commentForm" onSubmit={this.handleSubmit}>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
placeholder="Your name"
|
|
||||||
value={this.state.author}
|
|
||||||
onChange={this.handleAuthorChange}
|
|
||||||
/>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
placeholder="Say something..."
|
|
||||||
value={this.state.text}
|
|
||||||
onChange={this.handleTextChange}
|
|
||||||
/>
|
|
||||||
<input type="submit" value="Post" />
|
|
||||||
</form>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
var CommentBox = React.createClass({
|
|
||||||
getInitialState: function() {
|
|
||||||
return {data: []};
|
|
||||||
},
|
|
||||||
loadCommentsFromServer: function() {
|
|
||||||
$.ajax({
|
|
||||||
url: this.props.url,
|
|
||||||
dataType: 'json',
|
|
||||||
cache: false,
|
|
||||||
success: function(data) {
|
|
||||||
this.setState({data: data});
|
|
||||||
}.bind(this),
|
|
||||||
error: function(xhr, status, err) {
|
|
||||||
console.error(this.props.url, status, err.toString());
|
|
||||||
}.bind(this)
|
|
||||||
});
|
|
||||||
},
|
|
||||||
handleCommentSubmit: function(comment) {
|
|
||||||
var comments = this.state.data;
|
|
||||||
comment.id = Date.now();
|
|
||||||
var newComments = comments.concat([comment]);
|
|
||||||
this.setState({data: newComments});
|
|
||||||
$.ajax({
|
|
||||||
url: this.props.url,
|
|
||||||
method: 'POST',
|
|
||||||
dataType: 'json',
|
|
||||||
data: comment,
|
|
||||||
success: function(data) {
|
|
||||||
this.setState({data: data});
|
|
||||||
}.bind(this),
|
|
||||||
error: function(xhr, status, err) {
|
|
||||||
this.setState({data: comments});
|
|
||||||
console.error(this.props.url, status, err.toString());
|
|
||||||
}.bind(this)
|
|
||||||
});
|
|
||||||
},
|
|
||||||
componentDidMount: function() {
|
|
||||||
this.loadCommentsFromServer();
|
|
||||||
setInterval(this.loadCommentsFromServer, this.props.pollInterval);
|
|
||||||
},
|
|
||||||
render: function() {
|
|
||||||
return (
|
|
||||||
<div className="commentBox">
|
|
||||||
<h1>Comments</h1>
|
|
||||||
<CommentList data={this.state.data}/>
|
|
||||||
<CommentForm onCommentSubmit={this.handleCommentSubmit}/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
var CommentList = React.createClass({
|
|
||||||
render: function() {
|
|
||||||
var commentNodes = this.props.data.map( function(comment) {
|
|
||||||
return (
|
|
||||||
<Comment author={comment.author} key={comment.id}>{comment.text}</Comment>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
return (
|
|
||||||
<div className="commentList">
|
|
||||||
{commentNodes}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
ReactDOM.render(
|
|
||||||
<CommentBox url="/api/comments" pollInterval={2000}/>,
|
|
||||||
document.getElementById('content')
|
|
||||||
);
|
|
||||||
Reference in New Issue
Block a user