Skip to content

Commit 24a9fb3

Browse files
Initial webpack prod setup
1 parent 0d4c30f commit 24a9fb3

11 files changed

+907
-39
lines changed

package-lock.json

+801-36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+11-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
"main": "src/main.js",
66
"scripts": {
77
"start": "webpack-dev-server --mode development --open --hot",
8-
"build": "webpack --mode production",
8+
"prebuild": "rimraf dist",
9+
"build": "cross-env NODE_ENV=production webpack -p --config webpack.config.production.js",
10+
"dev": "webpack -d --config webpack.config.development.js --watch --hot",
911
"electron": "electron .",
1012
"lint": "eslint ."
1113
},
1214
"author": "Blessing Ebowe, Brian Taylor, Erik Gunther",
1315
"license": "MIT",
1416
"dependencies": {
17+
"@material-ui/core": "^1.4.1",
18+
"autoprefixer": "^9.0.1",
1519
"electron": "^2.0.5",
1620
"react": "^16.2.0",
1721
"react-dom": "^16.2.0",
@@ -23,14 +27,20 @@
2327
"babel-loader": "^7.1.4",
2428
"babel-preset-env": "^1.6.1",
2529
"babel-preset-react": "^6.24.1",
30+
"babel-preset-stage-1": "^6.24.1",
31+
"cross-env": "^5.2.0",
2632
"css-loader": "^0.28.11",
2733
"eslint": "^4.19.0",
2834
"eslint-config-airbnb-base": "^13.0.0",
2935
"eslint-plugin-babel": "^5.1.0",
3036
"eslint-plugin-import": "^2.13.0",
3137
"eslint-plugin-jsx-a11y": "^6.1.1",
3238
"eslint-plugin-react": "^7.10.0",
39+
"extract-text-webpack-plugin": "^4.0.0-beta.0",
3340
"html-webpack-plugin": "^3.1.0",
41+
"postcss-loader": "^2.1.6",
42+
"rimraf": "^2.6.2",
43+
"sass-loader": "^7.0.3",
3444
"style-loader": "^0.20.3",
3545
"webpack": "^4.4.0",
3646
"webpack-cli": "^2.0.13",

postcss.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const prefixer = require('autoprefixer');
2+
3+
module.exports = {
4+
plugins: [prefixer],
5+
};

src/config/index.js

Whitespace-only changes.

src/containers/.gitkeep

Whitespace-only changes.

src/public/images/.gitkeep

Whitespace-only changes.

src/index.html src/public/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8-
<title>My React App</title>
8+
<title>React Proto</title>
99
</head>
1010

1111
<body>
File renamed without changes.

src/utils/.gitkeep

Whitespace-only changes.

webpack.config.js webpack.config.development.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
const path = require('path');
2+
const webpack = require('webpack');
23
const HtmlWebpackPlugin = require('html-webpack-plugin');
4+
const ExtractTextPlugin = require('extract-text-webpack-plugin');
5+
6+
const DIST_DIR = path.join(__dirname, 'dist');
7+
const SRC_DIR = path.join(__dirname, 'src');
38

49
module.exports = {
5-
entry: './src/index.js',
10+
entry: './index.js',
611
output: {
712
path: path.join(__dirname, '/dist'),
813
filename: 'index_bundle.js',

webpack.config.production.js

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
const path = require('path');
2+
const HtmlWebpackPlugin = require('html-webpack-plugin');
3+
const ExtractTextPlugin = require('extract-text-webpack-plugin');
4+
5+
const DIST_DIR = path.join(__dirname, 'dist');
6+
const SRC_DIR = path.join(__dirname, 'src');
7+
8+
module.exports = {
9+
mode: 'production',
10+
context: SRC_DIR,
11+
entry: {
12+
app: './index.js',
13+
vendor: [
14+
'@material-ui/core',
15+
],
16+
},
17+
output: {
18+
filename: 'js/bundle.[hash].js',
19+
path: DIST_DIR,
20+
publicPath: '/',
21+
},
22+
devtool: 'source-map',
23+
module: {
24+
rules: [
25+
{
26+
test: /\.(js|jsx)$/,
27+
exclude: /node_modules/,
28+
use: ['babel-loader'],
29+
},
30+
{
31+
test: /\.(s?css)$/,
32+
use: ExtractTextPlugin.extract({
33+
fallback: 'style-loader',
34+
use: [
35+
{
36+
loader: 'css-loader',
37+
options: {
38+
camelCase: true,
39+
sourceMap: true,
40+
},
41+
},
42+
{
43+
loader: 'postcss-loader',
44+
options: {
45+
config: {
46+
ctx: {
47+
autoprefixer: {
48+
browsers: 'last 2 versions',
49+
},
50+
},
51+
},
52+
},
53+
},
54+
{
55+
loader: 'sass-loader',
56+
},
57+
],
58+
}),
59+
},
60+
],
61+
},
62+
optimization: {
63+
splitChunks: {
64+
cacheGroups: {
65+
vendor: {
66+
chunks: 'initial',
67+
test: 'vendor',
68+
name: 'vendor',
69+
enforce: true,
70+
},
71+
},
72+
},
73+
},
74+
plugins: [
75+
new HtmlWebpackPlugin({
76+
template: 'public/index.html',
77+
}),
78+
new ExtractTextPlugin({
79+
filename: 'styles/styles.[hash].css',
80+
allChunks: true,
81+
}),
82+
],
83+
};

0 commit comments

Comments
 (0)