Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Commit

Permalink
Add support for typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
0livare committed Feb 28, 2018
1 parent 9914226 commit cc669d1
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 30 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"author": "Zach Posten",
"license": "MIT",
"dependencies": {
"@types/react": "^16.0.38",
"@types/react-dom": "^16.0.4",
"history": "^4.7.2",
"react": "^16.2.0",
"react-dom": "^16.2.0",
Expand All @@ -36,6 +38,7 @@
},
"devDependencies": {
"autoprefixer": "^8.0.0",
"awesome-typescript-loader": "^3.5.0",
"babel-cli": "6.16.0",
"babel-core": "6.17.0",
"babel-loader": "^7.1.2",
Expand Down Expand Up @@ -73,7 +76,9 @@
"redux-immutable-state-invariant": "^2.1.0",
"rimraf": "2.5.4",
"sass-loader": "^6.0.6",
"source-map-loader": "^0.2.3",
"style-loader": "0.13.1",
"typescript": "^2.7.2",
"webpack": "^3.0.0",
"webpack-dev-middleware": "1.11.0",
"webpack-hot-middleware": "2.18.2",
Expand Down
11 changes: 11 additions & 0 deletions src/components/Hello.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as React from "react";

export interface HelloProps { compiler: string; framework: string; }

// 'HelloProps' describes the shape of props.
// State is never set so we use the '{}' type.
export class Hello extends React.Component<HelloProps, {}> {
render() {
return (<h1>Hello from {this.props.compiler} and {this.props.framework}!</h1>);
}
}
9 changes: 9 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as React from "react";
import * as ReactDOM from "react-dom";

import { Hello } from "./components/Hello";

ReactDOM.render(
<Hello compiler="TypeScript" framework="React" />,
document.getElementById("app")
);
13 changes: 13 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"module": "commonjs",
"target": "esnext",
"jsx": "react"
},
"include": [
"./src/**/*"
]
}
68 changes: 38 additions & 30 deletions webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,16 @@ import webpack from 'webpack'


export default {
devtool: 'eval-source-map',
stats: {
assets: false,
cached: false,
cachedAssets: false,
children: false,
chunks: false,
chunkModules: false,
chunkOrigins: false,
colors: false,
depth: false,
entrypoints: false,
errors: true,
errorDetails: true,
hash: false,
maxModules: 0,
modules: false,
performance: false,
providedExports: false,
publicPath: false,
reasons: false,
source: false,
timings: false,
usedExports: false,
version: false,
warnings: false
},
entry: [
'react-hot-loader/patch',
'webpack-hot-middleware/client',
path.resolve(__dirname, 'src/index'),
path.resolve(__dirname, 'src/index.tsx'),
],
devtool: 'eval-source-map',
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".ts", ".tsx", ".js", ".json"],
},
target: 'web',
output: {
path: path.resolve(__dirname, 'src'),
Expand All @@ -53,7 +31,11 @@ export default {
],
module: {
rules: [
{test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'},
{test: /\.tsx?$/, exclude: /node_modules/, use: ['babel-loader', 'awesome-typescript-loader']},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" },

{test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel-loader'},
{test: /\.css$/, use: [
'style-loader',
'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
Expand All @@ -68,5 +50,31 @@ export default {
'sass-loader', // 1. Compile SASS into CSS
]},
]
}
},
stats: {
assets: false,
cached: false,
cachedAssets: false,
children: false,
chunks: false,
chunkModules: false,
chunkOrigins: false,
colors: false,
depth: false,
entrypoints: false,
errors: true,
errorDetails: true,
hash: false,
maxModules: 0,
modules: false,
performance: false,
providedExports: false,
publicPath: false,
reasons: false,
source: false,
timings: false,
usedExports: false,
version: false,
warnings: false
},
}

0 comments on commit cc669d1

Please sign in to comment.