Skip to content

Commit f37ac77

Browse files
committed
Added production environment
1 parent 3423774 commit f37ac77

9 files changed

+21
-8
lines changed

Diff for: .env.development

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
environment="development"

Diff for: .env.production

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
environment="production"

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ You will need to install the following modules for optimization reasons
2929
# install node JS here: https://nodejs.org/en/download/
3030
# install yarn here: https://classic.yarnpkg.com/en/docs/install
3131
# install ngrok here: https://ngrok.com/download
32-
> yarn global add npx cross-env
32+
> yarn global add env-cmd
3333
> cd path_to_your_project
3434
> yarn install
3535
> yarn start

Diff for: package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"author": "Kana00",
55
"license": "SEE LICENSE IN ./LICENSE",
66
"scripts": {
7-
"start": "npx webpack-dev-server --open --hot",
8-
"build": "cross-env NODE_ENV=production webpack --config ./webpack.config.js",
7+
"start:development": "env-cmd -f .env.development webpack-dev-server --open --hot",
8+
"build": "webpack --config ./webpack.config.js",
99
"shareProduction": "ngrok http -bind-tls=true file:///Users/YOUR_USER/Documents/web-site-new-project/dist",
1010
"shareWebpack": "ngrok http localhost:8080 -bind-tls=true -host-header='localhost:8080'",
1111
"test": "npx jest"
@@ -41,6 +41,7 @@
4141
},
4242
"dependencies": {
4343
"@reach/router": "^1.3.3",
44+
"@types/node": "^14.14.22",
4445
"@types/reach__router": "^1.3.1",
4546
"@unly/universal-language-detector": "^2.0.3",
4647
"apollo-cache-inmemory": "^1.6.5",

Diff for: src/start.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ const apolloClient: ApolloClient<NormalizedCacheObject> = new ApolloClient({
2626
link
2727
});
2828

29-
3029
class App extends React.Component<any, {}> {
3130

32-
3331
componentDidMount() {
3432
document.title = 'React Application';
3533
}

Diff for: src/typings/custom_extension.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,22 @@ declare module "*.woff" {
2222
const url: string;
2323
export default url;
2424
}
25+
2526
declare module "*.woff2" {
2627
const url: string;
2728
export default url;
2829
}
30+
2931
declare module "*.eot" {
3032
const url: string;
3133
export default url;
3234
}
35+
3336
declare module "*.ttf" {
3437
const url: string;
3538
export default url;
3639
}
40+
3741
declare module "*.otf" {
3842
const url: string;
3943
export default url;

Diff for: src/typings/environment.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare namespace NodeJS {
2+
interface ProcessEnv {
3+
ENVIRONMENT: 'development' | 'production';
4+
}
5+
}

Diff for: webpack.config.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
33
const WebpackCleanupPlugin = require('webpack-cleanup-plugin');
44
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
55

6-
const isInProduction = process.env.NODE_ENV === 'production';
7-
86
module.exports = {
97
entry: {
108
/* All files that need to be grouped together into a <script src='...'> */
@@ -16,7 +14,7 @@ module.exports = {
1614
filename: '[name]_[hash].bundle.js',
1715
publicPath: "/"
1816
},
19-
mode: (isInProduction) ? 'production' : 'development',
17+
mode: (process.env.environment === 'production') ? 'production' : 'development',
2018
devtool: 'inline-source-map',
2119
devServer: {
2220
contentBase: './dist',

Diff for: yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -2426,6 +2426,11 @@
24262426
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.31.tgz#d6b4f9645fee17f11319b508fb1001797425da51"
24272427
integrity sha512-T+wnJno8uh27G9c+1T+a1/WYCHzLeDqtsGJkoEdSp2X8RTh3oOCZQcUnjAx90CS8cmmADX51O0FI/tu9s0yssg==
24282428

2429+
"@types/node@^14.14.22":
2430+
version "14.14.22"
2431+
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.22.tgz#0d29f382472c4ccf3bd96ff0ce47daf5b7b84b18"
2432+
integrity sha512-g+f/qj/cNcqKkc3tFqlXOYjrmZA+jNBiDzbP3kH+B+otKFqAdPgVTGP1IeKRdMml/aE69as5S4FqtxAbl+LaMw==
2433+
24292434
"@types/parse5@^5.0.3":
24302435
version "5.0.3"
24312436
resolved "https://registry.yarnpkg.com/@types/parse5/-/parse5-5.0.3.tgz#e7b5aebbac150f8b5fdd4a46e7f0bd8e65e19109"

0 commit comments

Comments
 (0)