Skip to content

Commit 982001f

Browse files
committed
chore: set up enviroment
Still a WIP but most of the main pieces are now in place.
0 parents  commit 982001f

9 files changed

+225
-0
lines changed

.babelrc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"presets": [
3+
"es2015",
4+
"react"
5+
],
6+
7+
"plugins": [
8+
"transform-object-rest-spread"
9+
]
10+
}

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Top-most EditorConfig file
2+
root = true
3+
4+
# 4 space indentation
5+
[*.{js,jsx,scss}]
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 4
9+
10+
# Format Config
11+
[{package.json,.editorconfig,.babelrc,.eslintrc}]
12+
indent_style = space
13+
indent_size = 2

.eslintrc

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"root": true,
3+
"extends": "eslint:recommended",
4+
"parser": "babel-eslint",
5+
6+
"env": {
7+
"browser": true,
8+
"es6": true,
9+
"node": true
10+
},
11+
12+
"plugins": [
13+
"react"
14+
],
15+
16+
"rules": {
17+
"no-undef": 2,
18+
"no-unreachable": 2,
19+
"no-unused-vars": 0,
20+
"no-console": 0,
21+
"semi": [ "error", "always" ]
22+
}
23+
}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

.postcssrc.js

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

package.json

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "webpack.vote",
3+
"version": "0.1.0",
4+
"description": "An application for casting votes on new webpack features and fixes.",
5+
"main": "dist/app.min.js",
6+
"scripts": {
7+
"start": "webpack-dev-server --config webpack.dev.babel.js --env.dev",
8+
"build": "webpack --config webpack.dist.babel.js",
9+
"test": "echo \"Error: no test specified\" && exit 1"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/webpack-contrib/voting-app.git"
14+
},
15+
"keywords": [
16+
"webpack",
17+
"vote",
18+
"voting"
19+
],
20+
"author": "Greg Venech",
21+
"license": "ISC",
22+
"bugs": {
23+
"url": "https://github.com/webpack-contrib/voting-app/issues"
24+
},
25+
"homepage": "https://github.com/webpack-contrib/voting-app#readme",
26+
"devDependencies": {
27+
"autoprefixer": "^6.7.7",
28+
"babel-core": "^6.24.1",
29+
"babel-eslint": "^7.2.2",
30+
"babel-loader": "^6.4.1",
31+
"babel-plugin-transform-object-rest-spread": "^6.23.0",
32+
"babel-preset-es2015": "^6.24.1",
33+
"babel-preset-react": "^6.24.1",
34+
"css-loader": "^0.28.0",
35+
"eslint": "^3.19.0",
36+
"eslint-loader": "^1.7.1",
37+
"eslint-plugin-react": "^6.10.3",
38+
"file-loader": "^0.11.1",
39+
"html-webpack-plugin": "^2.28.0",
40+
"html-webpack-template": "^6.0.1",
41+
"image-webpack-loader": "^2.0.0",
42+
"node-sass": "^4.5.2",
43+
"postcss-loader": "^1.3.3",
44+
"sass-loader": "^6.0.3",
45+
"style-loader": "^0.16.1",
46+
"webpack": "^2.4.1",
47+
"webpack-dev-server": "^2.4.2",
48+
"webpack-merge": "^4.1.0"
49+
},
50+
"dependencies": {
51+
"react": "^15.5.4",
52+
"react-dom": "^15.5.4"
53+
}
54+
}

webpack.common.babel.js

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import Path from 'path'
2+
import Webpack from 'webpack'
3+
4+
export default (env = {}) => ({
5+
context: Path.resolve(__dirname, './src'),
6+
entry: {
7+
index: './app.jsx'
8+
},
9+
10+
resolve: {
11+
symlinks: false,
12+
extensions: [ '.js', '.jsx', '.scss' ],
13+
alias: {
14+
Components: Path.resolve(__dirname, './src/components'),
15+
Utils: Path.resolve(__dirname, './src/utils')
16+
}
17+
},
18+
19+
module: {
20+
rules: [
21+
{
22+
test: /\.jsx?$/,
23+
exclude: /node_modules/,
24+
use: [
25+
'babel-loader',
26+
{
27+
loader: 'eslint-loader',
28+
options: {
29+
fix: true,
30+
configFile: Path.resolve(__dirname, './.eslintrc')
31+
}
32+
}
33+
]
34+
},
35+
{
36+
test: /\.s?css$/,
37+
use: [
38+
'style-loader',
39+
'css-loader',
40+
'postcss-loader',
41+
{
42+
loader: 'sass-loader',
43+
options: {
44+
includePaths: [
45+
Path.resolve(__dirname, './src/utils/scss')
46+
]
47+
}
48+
}
49+
]
50+
},
51+
{
52+
test: /\.(jpg|png|svg)$/,
53+
use: [
54+
'file-loader',
55+
'image-webpack-loader'
56+
]
57+
}
58+
]
59+
},
60+
61+
plugins: [
62+
new Webpack.DefinePlugin({
63+
'process.env.NODE_ENV': env.dev ? `'development'` : `'production'`
64+
})
65+
],
66+
67+
output: {
68+
path: Path.resolve(__dirname, './dist'),
69+
publicPath: '/',
70+
filename: 'app.min.js'
71+
}
72+
})

webpack.dev.babel.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import Path from 'path'
2+
import Webpack from 'webpack'
3+
import HTMLPlugin from 'html-webpack-plugin'
4+
import HTMLTemplate from 'html-webpack-template'
5+
import Merge from 'webpack-merge'
6+
7+
import CommonConfig from './webpack.common.babel.js'
8+
9+
export default env => Merge(CommonConfig(env), {
10+
devtool: 'source-map',
11+
12+
plugins: [
13+
new HTMLPlugin({
14+
inject: false,
15+
template: HTMLTemplate,
16+
17+
title: 'Webpack | Vote (Development Mode)',
18+
appMountId: 'root',
19+
mobile: true,
20+
favicon: './favicon.ico'
21+
}),
22+
23+
new Webpack.HotModuleReplacementPlugin()
24+
],
25+
26+
devServer: {
27+
port: 3030,
28+
inline: true,
29+
compress: true,
30+
historyApiFallback: true,
31+
contentBase: Path.resolve(__dirname, './dist')
32+
}
33+
})

webpack.dist.babel.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Path from 'path'
2+
import Webpack from 'webpack'
3+
import Merge from 'webpack-merge'
4+
5+
import CommonConfig from './webpack.common.babel.js'
6+
7+
export default env => Merge(CommonConfig(env), {
8+
plugins: [
9+
new Webpack.optimize.UglifyJsPlugin({
10+
comments: false
11+
})
12+
]
13+
})

0 commit comments

Comments
 (0)