Open platform to collect and prioritize feedback
add webpack and front-end stuff
goenning52df5dbacc69
diff --git a/app/renderer.go b/app/renderer.goindex 045977039..dbb50f3bc 100644--- a/app/renderer.go+++ b/app/renderer.go@@ -81,7 +81,9 @@ func (r *HTMLRenderer) Render(w io.Writer, name string, data interface{}, c echom["CurrentUrl"] = protocol + c.Request().Host + c.Request().URL.String()files, _ := ioutil.ReadDir("dist/js")- m["JavaScriptBundle"] = files[0].Name()+ if len(files) > 0 {+ m["JavaScriptBundle"] = files[0].Name()+ }return tmpl.Execute(w, m)}diff --git a/app/router.go b/app/router.goindex baca5e966..be8a688b7 100644--- a/app/router.go+++ b/app/router.go@@ -58,7 +58,7 @@ func GetMainEngine(ctx *WechyServices) *echo.Echo {router.Renderer = NewHTMLRenderer(router.Logger)router.HTTPErrorHandler = errorHandler- router.Static("/favicon.ico", "public/imgs/favicon.ico")+ router.Static("/favicon.ico", "favicon.ico")router.Static("/assets", "dist")authGroup := router.Group("", identity.HostChecker(env.MustGet("AUTH_ENDPOINT")))diff --git a/public/imgs/favicon.ico b/favicon.icosimilarity index 100%rename from public/imgs/favicon.icorename to favicon.icodiff --git a/package.json b/package.jsonindex 5db9f9122..6113474cf 100644--- a/package.json+++ b/package.json@@ -5,19 +5,28 @@"repository": "https://github.com/WeCanHearYou/wechy","license": "GPL-3.0","scripts": {- "build": "rm -rf assets && webpack",+ "build": "rm -rf dist && webpack",+ "build:watch": "rm -rf dist && webpack --watch","postinstall": "npm run build"},"dependencies": {+ "react": "^15.4.2",+ "react-dom": "^15.4.2","semantic-ui-css": "^2.2.9"},"devDependencies": {"@types/jquery": "^2.0.41",+ "@types/react": "^15.0.16",+ "@types/react-dom": "^0.14.23",+ "clean-webpack-plugin": "^0.1.15","css-loader": "^0.27.3","file-loader": "^0.10.1",+ "on-build-webpack": "^0.1.0",+ "rimraf": "^2.6.1","style-loader": "^0.13.2","ts-loader": "^2.0.1","typescript": "^2.2.1",- "webpack": "^2.2.1"+ "webpack": "^2.2.1",+ "webpack-auto-clean-build-plugin": "^1.0.3"}}diff --git a/public/components/IdeaInput.tsx b/public/components/IdeaInput.tsxnew file mode 100644index 000000000..025bf83e8--- /dev/null+++ b/public/components/IdeaInput.tsx@@ -0,0 +1,9 @@+import * as React from "react";++export class IdeaInput extends React.Component<{}, {}> {+ render() {+ return <div className="ui fluid input">+ <input id="new-idea-input" type="text" placeholder="Enter your idea, new feature or suggestion here ..." />+ </div>;+ }+}\ No newline at end of filediff --git a/public/index.ts b/public/index.tsindex ae1c91a92..4d77cdbc6 100644--- a/public/index.ts+++ b/public/index.ts@@ -1,12 +1,15 @@import * as $ from "jquery";+import init from "./init"+(<any>window).$ = (<any>window).jQuery = $;import "semantic-ui-css/semantic.min.css";import "./css/main.css";import "semantic-ui-css/semantic.min.js";$(document).ready(() => {- console.log("It works 3.");+ init();+$(".ui.dropdown").dropdown();$('.menu .signin').popup({diff --git a/public/init.tsx b/public/init.tsxnew file mode 100644index 000000000..0e33a1ae8--- /dev/null+++ b/public/init.tsx@@ -0,0 +1,11 @@+import * as React from "react";+import * as ReactDOM from "react-dom";++import { IdeaInput } from "./components/IdeaInput";++export default function init() {+ ReactDOM.render(+ <IdeaInput />,+ document.getElementById("root")+ );+}\ No newline at end of filediff --git a/tsconfig.json b/tsconfig.jsonindex 484cf8513..379cdd562 100755--- a/tsconfig.json+++ b/tsconfig.json@@ -4,6 +4,7 @@"target": "es5","noImplicitAny": true,"strictNullChecks": true,- "sourceMap": true+ "sourceMap": true,+ "jsx": "react"}}\ No newline at end of filediff --git a/views/index.html b/views/index.htmlindex 01a18128a..bda135651 100644--- a/views/index.html+++ b/views/index.html@@ -10,9 +10,7 @@<div class="ui container"><h3>I want ...</h3>- <div class="ui fluid input">- <input id="new-idea-input" type="text" placeholder="Enter your idea, new feature or suggestion here ..." />- </div>+ <div id="root"></div><div id="new-idea-submit" class="ui grid"><div class="four wide column">diff --git a/webpack.config.js b/webpack.config.jsindex 1be982b29..07d3ebf4e 100755--- a/webpack.config.js+++ b/webpack.config.js@@ -1,4 +1,6 @@const path = require('path');+const CleanWebpackPlugin = require('clean-webpack-plugin');+var AutoCleanBuildPlugin = require('webpack-auto-clean-build-plugin');module.exports = {entry: "./public/index.ts",@@ -7,10 +9,13 @@ module.exports = {filename: "js/bundle.[chunkhash].js",publicPath: "/assets/"},+ resolve: {+ extensions: ['.ts', '.tsx', '.js']+ },module: {loaders: [{ test: /\.css$/, loader: "style-loader!css-loader" },- { test: /\.ts$/, loader: "ts-loader" },+ { test: /\.(ts|tsx)$/, loader: "ts-loader" },{test: /\.(eot|svg|ttf|woff|woff2)$/,loader: 'file-loader?name=fonts/[name].[hash].[ext]'@@ -20,5 +25,9 @@ module.exports = {loader: 'file-loader?name=images/[name].[hash].[ext]'}]- }+ },+ plugins: [+ new AutoCleanBuildPlugin()+ ],+ watch: true};\ No newline at end of file