| @@ -0,0 +1,21 @@ | ||
| var gulp = require('gulp'); | ||
| var webpack = require('webpack'); | ||
|
|
||
| var paths = { | ||
| static: './static/**/*.*', | ||
| dist: './dist' | ||
| }; | ||
|
|
||
| gulp.task('copy', function(){ | ||
| return gulp.src(paths.static) | ||
| .pipe(gulp.dest(paths.dist)); | ||
| }); | ||
|
|
||
| gulp.task('webpack', function(){ | ||
| webpack( | ||
| require('./webpack.config.js'), | ||
| function(err, stats) { | ||
| // console.log(err, stats); | ||
| } | ||
| ); | ||
| }); |
| @@ -0,0 +1,31 @@ | ||
| { | ||
| "name": "webpack-typescript-react-setup", | ||
| "version": "0.1.0", | ||
| "description": "", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1", | ||
| "tsd": "tsd install react --save" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/pixelbreaker/webpack-typescript-react-setup.git" | ||
| }, | ||
| "author": "", | ||
| "license": "ISC", | ||
| "bugs": { | ||
| "url": "https://github.com/pixelbreaker/webpack-typescript-react-setup/issues" | ||
| }, | ||
| "homepage": "https://github.com/pixelbreaker/webpack-typescript-react-setup#readme", | ||
| "devDependencies": { | ||
| "css-loader": "^0.19.0", | ||
| "gulp": "^3.9.0", | ||
| "path": "^0.12.7", | ||
| "react": "^0.13.3", | ||
| "style-loader": "^0.12.4", | ||
| "ts-loader": "^0.5.5", | ||
| "tsd": "^0.6.4", | ||
| "typescript": "^1.6.2", | ||
| "webpack": "^1.12.2" | ||
| } | ||
| } |
| @@ -0,0 +1,9 @@ | ||
| declare var require: { | ||
| <T>(path: string): T; | ||
| (paths: string[], callback: (...modules: any[]) => void): void; | ||
| ensure: (paths: string[], callback: (require: <T>(path: string) => T) => void) => void; | ||
| } | ||
|
|
||
| declare interface CssRequire { | ||
| (path:string): any; | ||
| } |
| @@ -0,0 +1,3 @@ | ||
| :local(.Entry) { | ||
| color: red; | ||
| } |
| @@ -0,0 +1,8 @@ | ||
| //import * as React from 'react'; | ||
| import * as React from 'react'; | ||
| import {Entry} from './modules/Entry.tsx'; | ||
|
|
||
| React.render( | ||
| <Entry name="Goodbye World!" />, | ||
| document.getElementById('content') | ||
| ); |
| @@ -0,0 +1,3 @@ | ||
| module.exports = function(path) { | ||
| return require('../css/' + path); | ||
| } |
| @@ -0,0 +1,17 @@ | ||
| import * as React from 'react'; | ||
| var cssRequire = require<CssRequire>('../helpers/CssRequire.js'); | ||
| var styles = cssRequire('Entry.css'); | ||
|
|
||
| export interface Props { | ||
| name: string; | ||
| } | ||
|
|
||
| export class Entry extends React.Component<Props, any> { | ||
| render() { | ||
| return ( | ||
| <div className={styles.Entry}> | ||
| {this.props.name} | ||
| </div> | ||
| ); | ||
| } | ||
| } |
| @@ -0,0 +1,9 @@ | ||
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| </head> | ||
| <body> | ||
| <script type="text/javascript" src="js/bundle.js" charset="utf-8"></script> | ||
| </body> | ||
| </html> |
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "es5", | ||
| "sourceMap": true, | ||
| "jsx": "react" | ||
| }, | ||
| "files": [ | ||
| "src/app.d.ts", | ||
| "typings/tsd.d.ts" | ||
| ] | ||
| } |
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "version": "v4", | ||
| "repo": "borisyankov/DefinitelyTyped", | ||
| "ref": "master", | ||
| "path": "typings", | ||
| "bundle": "typings/tsd.d.ts", | ||
| "installed": { | ||
| "react/react.d.ts": { | ||
| "commit": "32029fcb4e1a3ef8968711b545d77b584435729d" | ||
| }, | ||
| "typescript/typescript.d.ts": { | ||
| "commit": "32029fcb4e1a3ef8968711b545d77b584435729d" | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,32 @@ | ||
| var path = require('path'); | ||
|
|
||
| module.exports = { | ||
| context: __dirname, | ||
| entry: "./src/entry.tsx", | ||
| output: { | ||
| path: path.join(__dirname, "dist/js"), | ||
| filename: "bundle.js" | ||
| }, | ||
| // resolve: { | ||
| // root: [ | ||
| // path.join(__dirname, "src"), | ||
| // ] | ||
| // }, | ||
| // Currently we need to add '.ts' to resolve.extensions array. | ||
| resolve: { | ||
| extensions: ['', '.webpack.js', '.web.js', '.js', '.css', '.ts', '.tsx'] | ||
| }, | ||
| devtool: 'source-map', | ||
| module: { | ||
| loaders: [ | ||
| { | ||
| test: /\.tsx?$/, | ||
| loader: 'ts-loader' | ||
| }, | ||
| { | ||
| test: /\.css$/, | ||
| loader: "style-loader!css-loader?modules" | ||
| } | ||
| ] | ||
| } | ||
| }; |