Skip to content

Commit 0e06b5c

Browse files
committed
Initial commit with basic react website
1 parent bca181c commit 0e06b5c

File tree

132 files changed

+32890
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+32890
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
.DS_Store

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib"
3+
}

configs/jest.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"rootDir": "..",
3+
"testEnvironment": "jsdom",
4+
"coverageDirectory": "<rootDir>/tests/__coverage__/",
5+
"setupFiles": ["<rootDir>/tests/__mocks__/shim.js"],
6+
"roots": ["<rootDir>/src/", "<rootDir>/tests/"],
7+
"moduleNameMapper": {
8+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/tests/__mocks__/fileMock.js",
9+
"\\.(css|scss|less)$": "<rootDir>/tests/__mocks__/styleMock.js"
10+
},
11+
"moduleFileExtensions": ["ts", "tsx", "js", "jsx"],
12+
"transformIgnorePatterns": ["/node_modules/"],
13+
"testRegex": "/tests/.*\\.(ts|tsx)$",
14+
"moduleDirectories": ["node_modules"],
15+
"globals": {
16+
"DEVELOPMENT": false,
17+
"FAKE_SERVER": false
18+
}
19+
}

configs/webpack/common.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// shared config (dev and prod)
2+
const path = require("path");
3+
const webpack = require("webpack");
4+
var SpritesmithPlugin = require('webpack-spritesmith');
5+
6+
module.exports = {
7+
resolve: {
8+
extensions: [".js", ".jsx", ".ts", ".tsx"],
9+
modules: ["node_modules", "public"],
10+
},
11+
context: path.resolve(__dirname, "../../src/"),
12+
module: {
13+
rules: [
14+
{
15+
test: [/\.tsx?$/],
16+
use: ["ts-loader"],
17+
exclude: /node_modules/,
18+
},
19+
{
20+
test: /\.css$/,
21+
use: ["style-loader", "css-loader"],
22+
},
23+
{
24+
test: /\.(scss|sass)$/,
25+
use: ["style-loader", "css-loader", "sass-loader"],
26+
},
27+
],
28+
},
29+
plugins: [
30+
new webpack.ProvidePlugin({
31+
"React": "react",
32+
}),
33+
new SpritesmithPlugin({
34+
src: {
35+
cwd: path.resolve(__dirname, '../../public/icons'),
36+
glob: '*.png'
37+
},
38+
target: {
39+
image: path.resolve(__dirname, '../../public/sprite-sheet.png'),
40+
css: path.resolve(__dirname, '../../src/shared/sprite-sheet.scss')
41+
},
42+
apiOptions: {
43+
cssImageRef: "~sprite-sheet.png"
44+
}
45+
}),
46+
],
47+
performance: {
48+
hints: false,
49+
},
50+
};

configs/webpack/dev.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// development config
2+
const { merge } = require("webpack-merge");
3+
const HtmlWebpackPlugin = require("html-webpack-plugin");
4+
const commonConfig = require("./common");
5+
6+
module.exports = merge(commonConfig, {
7+
mode: "development",
8+
entry: [
9+
"react-hot-loader/patch", // activate HMR for React
10+
"webpack-dev-server/client?http://localhost:8080", // bundle the client for webpack-dev-server and connect to the provided endpoint
11+
"./index.tsx", // the entry point of our app
12+
],
13+
devServer: {
14+
hot: "only", // enable HMR on the server
15+
historyApiFallback: true, // fixes error 404-ish errors when using react router :see this SO question: https://stackoverflow.com/questions/43209666/react-router-v4-cannot-get-url
16+
},
17+
devtool: "cheap-module-source-map",
18+
plugins: [
19+
new HtmlWebpackPlugin({
20+
favicon: "../public/favicon.ico",
21+
template: "dev-index.html",
22+
}),
23+
],
24+
});

configs/webpack/prod.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// production config
2+
const CopyWebpackPlugin = require('copy-webpack-plugin');
3+
const HtmlWebpackPlugin = require("html-webpack-plugin");
4+
const { merge } = require("webpack-merge");
5+
const { resolve } = require("path");
6+
7+
const commonConfig = require("./common");
8+
const path = require('path');
9+
10+
module.exports = merge(commonConfig, {
11+
mode: "production",
12+
entry: "./index.tsx",
13+
output: {
14+
filename: "js/bundle.[contenthash].min.js",
15+
path: resolve(__dirname, "../../dist"),
16+
publicPath: "",
17+
},
18+
devtool: "source-map",
19+
plugins: [
20+
new HtmlWebpackPlugin({
21+
favicon: "../public/favicon.ico",
22+
template: "prod-index.html",
23+
}),
24+
new CopyWebpackPlugin({
25+
patterns: [
26+
{
27+
from: "*.png",
28+
context: path.resolve(__dirname, "..", "..", "public"),
29+
globOptions: {
30+
ignore: ["**/sprite-sheet.png"],
31+
},
32+
},
33+
],
34+
}),
35+
],
36+
});

0 commit comments

Comments
 (0)