16 |
{helloStr}
17 |
18 | This is a React.Component that has been Webpacked. Note that this
19 | source code, as well as the others, are published in the source map for this
20 | application.
21 |
22 |
23 | This is originally a TypeScript project that has been compiled to JS and then
24 | minified by Webpack's TerserPlugin. However, the source maps exist
25 | here, so we can extract them and recover the original build tree and source from
26 | these maps.
27 |
28 |
29 | To try it for yourself, run the source map script on this URI.
30 |
31 |
32 | );
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/example-react-ts-app/configs/webpack/common.js:
--------------------------------------------------------------------------------
1 | // shared config (dev and prod)
2 | const {resolve} = require('path');
3 | const {CheckerPlugin} = require('awesome-typescript-loader');
4 | const HtmlWebpackPlugin = require('html-webpack-plugin');
5 |
6 | module.exports = {
7 | resolve: {
8 | extensions: ['.ts', '.tsx', '.js', '.jsx'],
9 | },
10 | context: resolve(__dirname, '../../src'),
11 | module: {
12 | rules: [
13 | {
14 | test: /\.js$/,
15 | use: ['babel-loader', 'source-map-loader'],
16 | exclude: /node_modules/,
17 | },
18 | {
19 | test: /\.tsx?$/,
20 | use: ['babel-loader', 'awesome-typescript-loader'],
21 | },
22 | {
23 | test: /\.css$/,
24 | use: ['style-loader', { loader: 'css-loader', options: { importLoaders: 1 } }],
25 | },
26 | {
27 | test: /\.scss$/,
28 | loaders: [
29 | 'style-loader',
30 | { loader: 'css-loader', options: { importLoaders: 1 } },
31 | 'sass-loader',
32 | ],
33 | },
34 | {
35 | test: /\.(jpe?g|png|gif|svg)$/i,
36 | loaders: [
37 | 'file-loader?hash=sha512&digest=hex&name=img/[hash].[ext]',
38 | 'image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false',
39 | ],
40 | },
41 | ],
42 | },
43 | plugins: [
44 | new CheckerPlugin(),
45 | new HtmlWebpackPlugin({template: 'index.html.ejs',}),
46 | ],
47 | externals: {
48 | 'react': 'React',
49 | 'react-dom': 'ReactDOM',
50 | },
51 | performance: {
52 | hints: false,
53 | },
54 | };
55 |
--------------------------------------------------------------------------------
/example-react-ts-app/README.md:
--------------------------------------------------------------------------------
1 | # React Webpack Typescript Starter
2 | > Minimal starter with hot module replacement (HMR) for rapid development.
3 |
4 | * **[React](https://facebook.github.io/react/)** (16.x)
5 | * **[Webpack](https://webpack.js.org/)** (4.x)
6 | * **[Typescript](https://www.typescriptlang.org/)** (3.x)
7 | * **[Hot Module Replacement (HMR)](https://webpack.js.org/concepts/hot-module-replacement/)** using [React Hot Loader](https://github.com/gaearon/react-hot-loader) (4.x)
8 | * [Babel](http://babeljs.io/) (7.x)
9 | * [SASS](http://sass-lang.com/)
10 | * [Jest](https://facebook.github.io/jest/) - Testing framework for React applications
11 | * Production build script
12 | * Image loading/minification using [Image Webpack Loader](https://github.com/tcoopman/image-webpack-loader)
13 | * Typescript compiling using [Awesome Typescript Loader](https://github.com/s-panferov/awesome-typescript-loader) (5.x)
14 | * Code quality (linting) for Typescript.
15 |
16 | ## Installation
17 | 1. Clone/download repo
18 | 2. `yarn install` (or `npm install` for npm)
19 |
20 | ## Usage
21 | **Development**
22 |
23 | `yarn run start-dev`
24 |
25 | * Build app continuously (HMR enabled)
26 | * App served @ `http://localhost:8080`
27 |
28 | **Production**
29 |
30 | `yarn run start-prod`
31 |
32 | * Build app once (HMR disabled) to `/dist/`
33 | * App served @ `http://localhost:3000`
34 |
35 | ---
36 |
37 | **All commands**
38 |
39 | Command | Description
40 | --- | ---
41 | `yarn run start-dev` | Build app continuously (HMR enabled) and serve @ `http://localhost:8080`
42 | `yarn run start-prod` | Build app once (HMR disabled) to `/dist/` and serve @ `http://localhost:3000`
43 | `yarn run build` | Build app to `/dist/`
44 | `yarn run test` | Run tests
45 | `yarn run lint` | Run Typescript linter
46 | `yarn run start` | (alias of `yarn run start-dev`)
47 |
48 | **Note**: replace `yarn` with `npm` if you use npm.
49 |
50 | ## See also
51 | * [React Webpack Babel Starter](https://github.com/vikpe/react-webpack-babel-starter)
52 | * [Isomorphic Webapp Starter](https://github.com/vikpe/isomorphic-webapp-starter)
53 |
--------------------------------------------------------------------------------
/example-react-ts-app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-webpack-typescript-starter",
3 | "version": "0.1.0",
4 | "description": "Starter kit for React, Webpack (with Hot Module Replacement), Typescript and Babel.",
5 | "keywords": [
6 | "react",
7 | "webpack",
8 | "typescript",
9 | "babel",
10 | "sass",
11 | "hmr",
12 | "starter",
13 | "boilerplate"
14 | ],
15 | "author": "Viktor Persson",
16 | "license": "MIT",
17 | "repository": {
18 | "type": "git",
19 | "url": "git+https://github.com/vikpe/react-webpack-typescript-starter.git"
20 | },
21 | "bugs": {
22 | "url": "https://github.com/vikpe/react-webpack-typescript-starter/issues"
23 | },
24 | "homepage": "https://github.com/vikpe/react-webpack-typescript-starter",
25 | "scripts": {
26 | "build": "yarn run clean-dist && webpack -p --config=configs/webpack/prod.js",
27 | "clean-dist": "rm -f -r -d dist",
28 | "lint": "tslint './src/**/*.ts*' --format stylish --force",
29 | "start": "yarn run start-dev",
30 | "start-dev": "webpack-dev-server --config=configs/webpack/dev.js",
31 | "start-prod": "yarn run build && node express.js",
32 | "test": "jest --watch --coverage --config=configs/jest.json"
33 | },
34 | "devDependencies": {
35 | "@babel/cli": "^7.4.4",
36 | "@babel/core": "^7.4.5",
37 | "@babel/preset-env": "^7.4.5",
38 | "@babel/preset-react": "^7.0.0",
39 | "@types/jest": "^24.0.13",
40 | "@types/node": "^12.0.8",
41 | "@types/react": "^16.8.19",
42 | "@types/react-dom": "^16.8.4",
43 | "awesome-typescript-loader": "^5.2.1",
44 | "babel-loader": "^8.0.6",
45 | "css-loader": "^3.0.0",
46 | "express": "^4.17.1",
47 | "file-loader": "^4.0.0",
48 | "html-webpack-plugin": "^3.2.0",
49 | "image-webpack-loader": "^5.0.0",
50 | "jest": "^24.8.0",
51 | "node-sass": "^4.13.0",
52 | "react": "^16.8.6",
53 | "react-dom": "^16.8.6",
54 | "react-hot-loader": "^4.11.0",
55 | "sass-loader": "^7.1.0",
56 | "style-loader": "^0.23.1",
57 | "tslint": "^5.17.0",
58 | "typescript": "^3.5.1",
59 | "uglifyjs-webpack-plugin": "^2.1.3",
60 | "webpack": "^4.33.0",
61 | "webpack-cli": "^3.3.4",
62 | "webpack-dev-middleware": "^3.7.0",
63 | "webpack-dev-server": "^3.7.1",
64 | "webpack-merge": "^4.2.1"
65 | },
66 | "dependencies": {}
67 | }
68 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | .hypothesis/
51 | .pytest_cache/
52 |
53 | # Translations
54 | *.mo
55 | *.pot
56 |
57 | # Django stuff:
58 | *.log
59 | local_settings.py
60 | db.sqlite3
61 | db.sqlite3-journal
62 |
63 | # Flask stuff:
64 | instance/
65 | .webassets-cache
66 |
67 | # Scrapy stuff:
68 | .scrapy
69 |
70 | # Sphinx documentation
71 | docs/_build/
72 |
73 | # PyBuilder
74 | target/
75 |
76 | # Jupyter Notebook
77 | .ipynb_checkpoints
78 |
79 | # IPython
80 | profile_default/
81 | ipython_config.py
82 |
83 | # pyenv
84 | .python-version
85 |
86 | # pipenv
87 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
88 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
89 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
90 | # install all needed dependencies.
91 | #Pipfile.lock
92 |
93 | # celery beat schedule file
94 | celerybeat-schedule
95 |
96 | # SageMath parsed files
97 | *.sage.py
98 |
99 | # Environments
100 | .env
101 | .venv
102 | env/
103 | venv/
104 | ENV/
105 | env.bak/
106 | venv.bak/
107 |
108 | # Spyder project settings
109 | .spyderproject
110 | .spyproject
111 |
112 | # Rope project settings
113 | .ropeproject
114 |
115 | # mkdocs documentation
116 | /site
117 |
118 | # mypy
119 | .mypy_cache/
120 | .dmypy.json
121 | dmypy.json
122 |
123 | # Pyre type checker
124 | .pyre/
125 |
126 | .vscode/
127 | output/
128 |
--------------------------------------------------------------------------------
/example-react-ts-app/src/assets/img/react_logo.svg:
--------------------------------------------------------------------------------
1 |