Browse Source

Fixed build process a bit more; plus other stuff

update-deps
Alex Mikhalev 8 years ago
parent
commit
9632d35e23
  1. 1
      .gitignore
  2. 12
      app/index.html
  3. 4
      app/script/App.tsx
  4. 3
      app/script/index.tsx
  5. 6
      package.json
  6. 4
      webpack/dev.config.js
  7. 32
      webpack/prod.config.js

1
.gitignore vendored

@ -1,3 +1,4 @@
/node_modules /node_modules
npm-debug* npm-debug*
/build
/dist /dist

12
app/index.html

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sprinklers3</title>
</head>
<body>
<div id="app"></div>
<script src="/static/app.js"></script>
</body>
</html>

4
app/script/App.tsx

@ -38,10 +38,10 @@ class ProgramRow extends React.PureComponent<{ program: Program }, void> {
@observer @observer
class DeviceView extends React.PureComponent<{ device: SprinklersDevice }, void> { class DeviceView extends React.PureComponent<{ device: SprinklersDevice }, void> {
render() { render() {
const { id, connected, sections, programs } = this.props.device; //src={require("app/images/raspberry_pi.png")} const { id, connected, sections, programs } = this.props.device;
return ( return (
<Item> <Item>
<Item.Image /> <Item.Image src={require<string>("app/images/raspberry_pi.png")} />
<Item.Content> <Item.Content>
<Header as="h1"> <Header as="h1">
<span>Device </span><kbd>{id}</kbd> <span>Device </span><kbd>{id}</kbd>

3
app/script/index.tsx

@ -9,8 +9,7 @@ const client = new MqttApiClient();
client.start(); client.start();
const device = client.getDevice("grinklers"); const device = client.getDevice("grinklers");
const rootElem = document.createElement("div"); const rootElem = document.getElementById("app");
document.body.appendChild(rootElem);
ReactDOM.render(<AppContainer> ReactDOM.render(<AppContainer>
<App device={device} /> <App device={device} />

6
package.json

@ -6,9 +6,9 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"clean": "rm -rf ./dist", "clean": "rm -rf ./dist ./build",
"build": "webpack", "build": "webpack --config ./webpack/prod.config.js",
"start:dev": "webpack-dev-server" "start:dev": "webpack-dev-server --config ./webpack/dev.config.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

4
webpack.config.js → webpack/dev.config.js

@ -11,7 +11,7 @@ module.exports = {
], ],
devtool: "inline-source-map", devtool: "inline-source-map",
output: { output: {
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, "build"),
filename: "bundle.js" filename: "bundle.js"
}, },
resolve: { resolve: {
@ -29,7 +29,7 @@ module.exports = {
}, },
plugins: [ plugins: [
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
title: "sprinklers3" template: "./app/index.html"
}), }),
new webpack.NamedModulesPlugin(), new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin() new webpack.HotModuleReplacementPlugin()

32
webpack/prod.config.js

@ -0,0 +1,32 @@
const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
entry: [
"./app/script/index.tsx"
],
devtool: "none",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js"
},
resolve: {
extensions: [".ts", ".tsx", ".js"],
alias: {
app: path.resolve("./app")
}
},
module: {
rules: [
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
{ test: /\.css$/, loader: "style-loader!css-loader" },
{ test: /\.(ttf|eot|svg|woff(2)?|png|jpg)(\?[a-z0-9=&.]+)?$/, loader: "file-loader" }
]
},
plugins: [
new HtmlWebpackPlugin({
template: "./app/index.html"
})
]
};
Loading…
Cancel
Save