Skip to content
This repository was archived by the owner on Feb 19, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ build

# misc
.DS_Store
npm-debug.log
npm-debug.log
.vscode
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js

node_js:
- 4.2
- 4
- 5
- 6

Expand Down
8 changes: 4 additions & 4 deletions configuration/babel/babel.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ module.exports = {
babelrc: false,
cacheDirectory: true,
presets: [
'babel-preset-es2015',
'babel-preset-stage-0',
'babel-preset-react',
[ 'es2015', { loose: true, modules: false } ],
'stage-0',
'react'
],
plugins: ['react-hot-loader/babel'],
plugins: [ 'react-hot-loader/babel' ]
};
16 changes: 7 additions & 9 deletions configuration/babel/babel.prod.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
module.exports = {
babelrc: false,
presets: [
'babel-preset-es2015',
'babel-preset-stage-0',
'babel-preset-react'
[ 'es2015', { loose: true, modules: false } ],
'stage-0',
'react'
].map(require.resolve),
plugins: [
'babel-plugin-transform-react-constant-elements',
].map(require.resolve).concat([
[require.resolve('babel-plugin-transform-runtime')]
])
};
plugins: [ 'babel-plugin-transform-react-constant-elements' ]
.map(require.resolve)
.concat([ [ require.resolve('babel-plugin-transform-runtime') ] ])
};
4 changes: 2 additions & 2 deletions configuration/babel/babel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
presets: [
'babel-preset-es2015',
'babel-preset-stage-0',
'babel-preset-react',
'babel-preset-react'
],
plugins: ['istanbul'],
plugins: [ 'istanbul' ]
};
26 changes: 11 additions & 15 deletions configuration/eslint/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,28 @@ module.exports = {
root: true,
parser: 'babel-eslint',
extends: 'formidable/configurations/es6-react',
env: {
browser: true,
commonjs: true,
es6: true,
node: true,
mocha: true,
},
globals: {
'expect': true,
},
env: { browser: true, commonjs: true, es6: true, node: true, mocha: true },
globals: { expect: true },
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
generators: true,
experimentalObjectRestSpread: true,
},
experimentalObjectRestSpread: true
}
},
rules: {
'quotes': [2, 'single', { 'allowTemplateLiterals': true }],
quotes: [ 2, 'single', { allowTemplateLiterals: true } ],
'no-magic-numbers': 'off',
'func-style': 'off',
'arrow-parens': 'off',
'no-use-before-define': 'off',
'react/jsx-filename-extension': 'off',
'react/require-extension': 'off',
'react/no-multi-comp': 'warn',
'react/prop-types': 'warn',
'react/sort-comp': 'warn',
'react/sort-prop-types': 'warn',
},
'react/sort-prop-types': 'warn'
}
};
2 changes: 1 addition & 1 deletion configuration/polyfills/polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ if (typeof Promise === 'undefined') {
window.Promise = require('promise/lib/es6-extensions.js');
}

require('whatwg-fetch');
require('whatwg-fetch');
27 changes: 8 additions & 19 deletions configuration/webpack/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ module.exports = {
filename: 'static/js/bundle.js',
publicPath: '/'
},
resolve: {
extensions: ['.js', '.json']
},
resolve: { extensions: [ '.js', '.json' ] },
module: {
loaders: [
{
Expand All @@ -33,30 +31,21 @@ module.exports = {
},
{
test: /\.css$/,
include: [src, nodeModules],
include: [ src, nodeModules ],
loader: 'style-loader!css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss-loader'
},
{
test: /\.json$/,
include: [src, nodeModules],
loader: 'json-loader'
},
{ test: /\.json$/, include: [ src, nodeModules ], loader: 'json-loader' },
{
test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2)(\?.*)?$/,
include: [src, nodeModules],
include: [ src, nodeModules ],
loader: 'file-loader',
query: {
name: 'static/media/[name].[ext]'
}
query: { name: 'static/media/[name].[ext]' }
},
{
test: /\.(mp4|webm)(\?.*)?$/,
include: [src, nodeModules],
include: [ src, nodeModules ],
loader: 'url-loader',
query: {
limit: 10000,
name: 'static/media/[name].[ext]'
}
query: { limit: 10000, name: 'static/media/[name].[ext]' }
}
]
},
Expand All @@ -73,7 +62,7 @@ module.exports = {
useEslintrc: false
},
postcss() {
return [autoprefixer];
return [ autoprefixer ];
}
}
}),
Expand Down
70 changes: 25 additions & 45 deletions configuration/webpack/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');
const HtmlWebpackInlineSourcePlugin = require(
'html-webpack-inline-source-plugin'
);

const src = path.resolve('src');
const nodeModules = path.resolve('node_modules');
Expand All @@ -15,19 +17,14 @@ const publicPath = '/';
module.exports = {
bail: true,
devtool: 'source-map',
entry: [
require.resolve('../polyfills/polyfills'),
path.join(src, 'index')
],
entry: [ require.resolve('../polyfills/polyfills'), path.join(src, 'index') ],
output: {
path: path.resolve('build'),
filename: 'static/js/[name].[chunkhash:8].js',
chunkFilename: 'static/js/[name].[chunkhash:8].chunk.js',
publicPath
},
resolve: {
extensions: ['.js', '.json']
},
resolve: { extensions: [ '.js', '.json' ] },
module: {
loaders: [
{
Expand All @@ -38,36 +35,29 @@ module.exports = {
},
{
test: /\.css$/,
include: [src, nodeModules],
loader: ExtractTextPlugin.extract(
{
fallbackLoader: 'style-loader',
loader: 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]-autoprefixer!postcss-loader'
}
)
include: [ src, nodeModules ],
loader: ExtractTextPlugin.extract({
fallbackLoader: 'style-loader',
loader: 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]-autoprefixer!postcss-loader'
})
},
{
test: /\.json$/,
include: [src, nodeModules],
include: [ src, nodeModules ],
loader: 'json-loader',
exclude: /manifest.json$/
},
{
test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2)(\?.*)?$/,
include: [src, nodeModules],
include: [ src, nodeModules ],
loader: 'file-loader',
query: {
name: 'static/media/[name].[hash:8].[ext]'
}
query: { name: 'static/media/[name].[hash:8].[ext]' }
},
{
test: /\.(mp4|webm)(\?.*)?$/,
include: [src, nodeModules],
include: [ src, nodeModules ],
loader: 'url-loader',
query: {
limit: 10000,
name: 'static/media/[name].[hash:8].[ext]'
}
query: { limit: 10000, name: 'static/media/[name].[hash:8].[ext]' }
}
]
},
Expand Down Expand Up @@ -98,35 +88,25 @@ module.exports = {
useEslintrc: false
},
postcss() {
return [autoprefixer];
return [ autoprefixer ];
}
}
}),
new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"' }),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true,
warnings: false
},
mangle: {
screw_ie8: true
},
output: {
comments: false,
screw_ie8: true
}
compress: { screw_ie8: true, warnings: false },
mangle: { screw_ie8: true },
output: { comments: false, screw_ie8: true }
}),
new ExtractTextPlugin('static/css/[name].[contenthash:8].css'),
new CopyWebpackPlugin([
{ from: 'public' },
{ from: 'manifest.webmanifest' }
{ from: 'public' },
{ from: 'manifest.webmanifest' }
]),
new SWPrecacheWebpackPlugin(
{
cacheId: 'formidable-react-starter',
filename: 'service-worker.js'
}
)
new SWPrecacheWebpackPlugin({
cacheId: 'formidable-react-starter',
filename: 'service-worker.js'
})
]
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
"express": "^4.14.0",
"react": "^15.3.0",
"react-dom": "^15.3.0",
"react-helmet": "^4.0.0",
"react-hot-loader": "^3.0.0-beta.2",
"react-router": "^3.0.0",
"react-router-dom": "next",
"serve-favicon": "^2.3.0"
},
"devDependencies": {
Expand Down
20 changes: 9 additions & 11 deletions server/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,28 @@ process.env.NODE_ENV = 'development';
var PORT = process.env.PORT || 3000;

// Set up compiler

var compiler = webpack(config);

compiler.plugin('invalid', () => {
utils.clearConsole();
console.log('Compiling...');
});

compiler.plugin('done', (stats) => {
compiler.plugin('done', stats => {
utils.formatStats(stats, PORT);
});

// Launch server

var app = express();

app.use(historyApiFallback({
verbose: false
}));
app.use(historyApiFallback({ verbose: false }));

app.use(require('webpack-dev-middleware')(compiler, {
noInfo: true,
publicPath: config.output.publicPath,
}));
app.use(
require('webpack-dev-middleware')(compiler, {
noInfo: true,
publicPath: config.output.publicPath
})
);

app.use(require('webpack-hot-middleware')(compiler));

Expand All @@ -46,7 +44,7 @@ app.get('*', (req, res) => {
res.sendFile(path.resolve('index.html'));
});

app.listen(PORT, (err) => {
app.listen(PORT, err => {
if (err) {
console.log(err);
return;
Expand Down
3 changes: 1 addition & 2 deletions server/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ var utils = require('./utils');
var PORT = process.env.PORT || 80;

// Launch server

var app = express();

app.use(express.static('./build'));
Expand All @@ -20,7 +19,7 @@ app.get('*', (req, res) => {
res.sendFile(path.resolve('./build/index.html'));
});

app.listen(PORT, (err) => {
app.listen(PORT, err => {
if (err) {
console.log(err);
return;
Expand Down
Loading