From 1d990f63f26f03842a551c0da121d6654b11f18e Mon Sep 17 00:00:00 2001 From: Kai Moseley Date: Tue, 20 Sep 2016 17:58:31 +0100 Subject: [PATCH] Initial setup --- .babelrc | 4 +++ .eslintrc.js | 44 ++++++++++++++++++++++++++++++++ .flowconfig | 2 ++ .gitignore | 2 ++ package.json | 63 +++++++++++++++++++++++++++++++++++++++++++++ webpack.config.js | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 180 insertions(+) create mode 100644 .babelrc create mode 100644 .eslintrc.js create mode 100644 .flowconfig create mode 100644 .gitignore create mode 100644 package.json create mode 100644 webpack.config.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..b9b6bc3 --- /dev/null +++ b/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["es2015", "react"], + "plugins": ["transform-object-rest-spread", "syntax-async-functions", "transform-async-to-generator", "transform-flow-strip-types"] +} diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..4b237aa --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,44 @@ +module.exports = { + parserOptions: { + ecmaVersion: 6, + sourceType: 'module', + ecmaFeatures: { + jsx: true, + experimentalObjectRestSpread: true, + } + }, + plugins: [ + 'react', + 'flowtype', + ], + extends: [ + 'eslint:recommended', + 'plugin:react/recommended', + 'plugin:flowtype/recommended' + ], + settings: { + flowtype: { + onlyFilesWithFlowAnnotation: true, + } + }, + rules: { + 'react/prop-types': ['off'], + 'react/display-name': ['off'], + 'no-console': ['warn'], + //'arrow-parens': ['warn', 'as-needed'], + }, + env: { + browser: true, + node: true, + es6: true, + }, + globals: { + _: true, + _fmt: true, + _misc: true, + _arr: true, + _cfg: true, + Promise: true, + RE_CHILD_INDEX_JS: true, + } +}; \ No newline at end of file diff --git a/.flowconfig b/.flowconfig new file mode 100644 index 0000000..efe3848 --- /dev/null +++ b/.flowconfig @@ -0,0 +1,2 @@ +[ignore] +.*/node_modules/fbjs/* \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2361363 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/.idea/* +/node_modules/* \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..6aa6efe --- /dev/null +++ b/package.json @@ -0,0 +1,63 @@ +{ + "name": "react-custom-home", + "version": "0.0.0", + "description": "A customisable home screen", + "main": "index.js", + "scripts": { + "start": "webpack-dev-server --progress --content-base dist/", + "test": "jest" + }, + "jest": { + "testPathDirs": [ + "/src" + ], + "moduleFileExtensions": [ + "js", + "jsx", + "json" + ], + "moduleDirectories": [ + "node_modules" + ], + "modulePaths": [ + "/src" + ], + "moduleNameMapper": { + "^.+\\.(css|less|scss)$": "/src/__mocks__/styleMock.js", + "^.+\\.(gif|ttf|eot|svg)$": "/src/__mocks__/fileMock.js" + } + }, + "author": "Kai Moseley", + "license": "ISC", + "devDependencies": { + "babel-eslint": "^6.1.2", + "babel-loader": "^6.2.5", + "babel-plugin-syntax-async-functions": "^6.13.0", + "babel-plugin-transform-async-to-generator": "^6.8.0", + "babel-plugin-transform-flow-strip-types": "^6.14.0", + "babel-plugin-transform-object-rest-spread": "^6.8.0", + "babel-preset-es2015": "^6.14.0", + "babel-preset-react": "^6.11.1", + "body-parser": "^1.15.2", + "css-loader": "^0.24.0", + "enzyme": "^2.4.1", + "eslint": "^3.2.2", + "eslint-loader": "^1.5.0", + "eslint-plugin-babel": "^3.3.0", + "eslint-plugin-flowtype": "^2.18.1", + "eslint-plugin-react": "^6.0.0", + "express": "^4.14.0", + "flow-bin": "^0.32.0", + "jest": "^15.1.1", + "lodash": "^4.15.0", + "node-sass": "^3.8.0", + "react": "^15.3.1", + "react-css-modules": "^3.7.9", + "react-dom": "^15.3.1", + "react-redux": "^4.4.5", + "sass-loader": "^4.0.0", + "style-loader": "^0.13.1", + "webpack": "^1.13.2", + "webpack-dev-server": "^1.16.1" + } +} diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..8dd5ca3 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,65 @@ +const webpack = require('webpack'); +const path = require('path'); +const _ = require('lodash'); + +const PATH_ESLINT = path.join(__dirname, '.eslintrc.js'); +const PATH_SRC = path.join(__dirname, 'src/client/'); +const PATH_ALIASES = _.mapValues({ + 'home-screen': 'src/client/home-screen', +}, relativePath => path.join(__dirname, relativePath)); + +module.exports = { + context: __dirname, + entry: { + 'home-screen': './src/client/home-screen' + }, + devServer: { + inline: true, + }, + output: { + path: path.join(__dirname, 'dist'), + filename: '[name].bundle.js', + }, + devtool: 'inline-source-map', + eslint: { + configFile: PATH_ESLINT, + }, + module: { + loaders: [ + { + test: /\.(js|jsx)$/, + include: [PATH_SRC], + exclude: [], + loader: "babel-loader", + }, + { + test: /\.css$/, + loaders: ['style', 'css', 'sass'] + }, + { + test: /\.scss$/, + loaders: [ + 'style', + 'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]', + 'sass' + ] + } + ], + preLoaders: [ { test: /\.js$/, include: [PATH_SRC], loader: 'eslint-loader' } ] + }, + resolve: { + extensions: ['', '.js', '.json', '.jsx'], + alias: PATH_ALIASES, + }, + plugins: [ + new webpack.ProvidePlugin({ + _: 'lodash' + }), + function () { + this.plugin('done', () => + setTimeout(() => console.log('\nFinished at ' + (new Date).toLocaleTimeString() + '\n'), 10) + ); + }, + new webpack.HotModuleReplacementPlugin(), + ] +}; \ No newline at end of file