Skip to content

Commit

Permalink
Initial webpack prod setup
Browse files Browse the repository at this point in the history
  • Loading branch information
refinedblessing committed Jul 25, 2018
1 parent 0d4c30f commit 24a9fb3
Show file tree
Hide file tree
Showing 11 changed files with 907 additions and 39 deletions.
837 changes: 801 additions & 36 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion package.json
Expand Up @@ -5,13 +5,17 @@
"main": "src/main.js",
"scripts": {
"start": "webpack-dev-server --mode development --open --hot",
"build": "webpack --mode production",
"prebuild": "rimraf dist",
"build": "cross-env NODE_ENV=production webpack -p --config webpack.config.production.js",
"dev": "webpack -d --config webpack.config.development.js --watch --hot",
"electron": "electron .",
"lint": "eslint ."
},
"author": "Blessing Ebowe, Brian Taylor, Erik Gunther",
"license": "MIT",
"dependencies": {
"@material-ui/core": "^1.4.1",
"autoprefixer": "^9.0.1",
"electron": "^2.0.5",
"react": "^16.2.0",
"react-dom": "^16.2.0",
Expand All @@ -23,14 +27,20 @@
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-1": "^6.24.1",
"cross-env": "^5.2.0",
"css-loader": "^0.28.11",
"eslint": "^4.19.0",
"eslint-config-airbnb-base": "^13.0.0",
"eslint-plugin-babel": "^5.1.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-react": "^7.10.0",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"html-webpack-plugin": "^3.1.0",
"postcss-loader": "^2.1.6",
"rimraf": "^2.6.2",
"sass-loader": "^7.0.3",
"style-loader": "^0.20.3",
"webpack": "^4.4.0",
"webpack-cli": "^2.0.13",
Expand Down
5 changes: 5 additions & 0 deletions postcss.config.js
@@ -0,0 +1,5 @@
const prefixer = require('autoprefixer');

module.exports = {
plugins: [prefixer],
};
Empty file added src/config/index.js
Empty file.
Empty file added src/containers/.gitkeep
Empty file.
Empty file added src/public/images/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion src/index.html → src/public/index.html
Expand Up @@ -5,7 +5,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>My React App</title>
<title>React Proto</title>
</head>

<body>
Expand Down
File renamed without changes.
Empty file added src/utils/.gitkeep
Empty file.
7 changes: 6 additions & 1 deletion webpack.config.js → webpack.config.development.js
@@ -1,8 +1,13 @@
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');

const DIST_DIR = path.join(__dirname, 'dist');
const SRC_DIR = path.join(__dirname, 'src');

module.exports = {
entry: './src/index.js',
entry: './index.js',
output: {
path: path.join(__dirname, '/dist'),
filename: 'index_bundle.js',
Expand Down
83 changes: 83 additions & 0 deletions webpack.config.production.js
@@ -0,0 +1,83 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');

const DIST_DIR = path.join(__dirname, 'dist');
const SRC_DIR = path.join(__dirname, 'src');

module.exports = {
mode: 'production',
context: SRC_DIR,
entry: {
app: './index.js',
vendor: [
'@material-ui/core',
],
},
output: {
filename: 'js/bundle.[hash].js',
path: DIST_DIR,
publicPath: '/',
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
{
test: /\.(s?css)$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
camelCase: true,
sourceMap: true,
},
},
{
loader: 'postcss-loader',
options: {
config: {
ctx: {
autoprefixer: {
browsers: 'last 2 versions',
},
},
},
},
},
{
loader: 'sass-loader',
},
],
}),
},
],
},
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
chunks: 'initial',
test: 'vendor',
name: 'vendor',
enforce: true,
},
},
},
},
plugins: [
new HtmlWebpackPlugin({
template: 'public/index.html',
}),
new ExtractTextPlugin({
filename: 'styles/styles.[hash].css',
allChunks: true,
}),
],
};

0 comments on commit 24a9fb3

Please sign in to comment.