Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ssarkisy committed Oct 20, 2017
0 parents commit 944dcdd
Show file tree
Hide file tree
Showing 13 changed files with 313 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"plugins": [
["import", {
"libraryName": "antd",
"style": "css"
}]
],
"presets": ["react", "env", "stage-1"]
}
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
63 changes: 63 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"plugins": [
"react"
],
"parser": "babel-eslint",
"env": {
"es6": true,
"browser": true,
"node": true,
"mocha": true
},
"rules": {
"quotes": 0,
"no-console": 1,
"no-debugger": 1,
"no-var": 1,
"semi": [1, "always"],
"no-trailing-spaces": 0,
"eol-last": 0,
"no-unused-vars": 0,
"no-underscore-dangle": 0,
"no-alert": 0,
"no-lone-blocks": 0,
"jsx-quotes": 1,
"react/display-name": [ 1, {"ignoreTranspilerName": false }],
"react/forbid-prop-types": [1, {"forbid": ["any"]}],
"react/jsx-boolean-value": 1,
"react/jsx-closing-bracket-location": 0,
"react/jsx-curly-spacing": 1,
"react/jsx-indent-props": 0,
"react/jsx-key": 1,
"react/jsx-max-props-per-line": 0,
"react/jsx-no-bind": 1,
"react/jsx-no-duplicate-props": 1,
"react/jsx-no-literals": 0,
"react/jsx-no-undef": 1,
"react/jsx-pascal-case": 1,
"react/jsx-sort-prop-types": 0,
"react/jsx-sort-props": 0,
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/jsx-wrap-multilines": 1,
"react/no-danger": 1,
"react/no-did-mount-set-state": 1,
"react/no-did-update-set-state": 1,
"react/no-direct-mutation-state": 1,
"react/no-multi-comp": 0,
"react/no-set-state": 0,
"react/no-unknown-property": 1,
"react/prefer-es6-class": 1,
"react/prop-types": 1,
"react/react-in-jsx-scope": 1,
"react/self-closing-comp": 1,
"react/sort-comp": 1,
"import/no-named-as-default" : 0,
"import/extensions": 1
}
}
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
/node_modules

#IDE
/.idea

#production
/dist

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
Empty file added README.md
Empty file.
41 changes: 41 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "react2",
"version": "0.1.0",
"private": true,
"scripts": {
"lint": "node_modules/.bin/eslint webpack.config.* src tools",
"clean-dist": "npm run remove-dist && mkdir dist",
"remove-dist": "node_modules/.bin/rimraf ./dist",
"prebuild": "npm-run-all clean-dist lint",
"build": "babel-node tools/build.js"
},
"dependencies": {
"antd": "2.13.6",
"babel-polyfill": "^6.26.0",
"react": "15.6.2",
"react-dom": "15.6.2",
"react-scripts": "1.0.14"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-import": "^1.6.2",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-1": "^6.24.1",
"babel-register": "^6.26.0",
"colors": "^1.1.2",
"css-loader": "^0.28.7",
"eslint": "4.9.0",
"eslint-plugin-import": "2.8.0",
"eslint-plugin-react": "7.4.0",
"extract-text-webpack-plugin": "^3.0.1",
"file-loader": "^1.1.5",
"npm-run-all": "^4.1.1",
"rimraf": "^2.6.2",
"style-loader": "^0.19.0",
"url-loader": "^0.6.2",
"webpack": "^3.8.1"
}
}
39 changes: 39 additions & 0 deletions src/components/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React, { Component } from 'react';

import { Layout, Menu, Breadcrumb } from 'antd';
const { Header, Content, Footer } = Layout;

class App extends Component {
render() {
return (
<Layout className="layout">
<Header>
<div className="logo" />
<Menu
theme="dark"
mode="horizontal"
defaultSelectedKeys={['2']}
style={{ lineHeight: '64px' }}
>
<Menu.Item key="1">nav 1</Menu.Item>
<Menu.Item key="2">nav 2</Menu.Item>
<Menu.Item key="3">nav 3</Menu.Item>
</Menu>
</Header>
<Content style={{ padding: '0 50px' }}>
<Breadcrumb style={{ margin: '16px 0' }}>
<Breadcrumb.Item>Home</Breadcrumb.Item>
<Breadcrumb.Item>List</Breadcrumb.Item>
<Breadcrumb.Item>App</Breadcrumb.Item>
</Breadcrumb>
<div style={{ background: '#fff', padding: 24, minHeight: 280 }}>Content</div>
</Content>
<Footer style={{ textAlign: 'center' }}>
Ant Design ©2016 Created by Ant UED
</Footer>
</Layout>
);
}
}

export default App;
Binary file added src/favicon.ico
Binary file not shown.
14 changes: 14 additions & 0 deletions src/index.csp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Сахалинский областной медицинский информационно-аналитический центр</title>
</head>
<body>
<div id="app"></div>
<script src="./bundle.js"></script>
</body>
</html>
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App';
import './index.csp';

ReactDOM.render(<App />, document.getElementById('app'));
7 changes: 7 additions & 0 deletions src/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions tools/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*eslint-disable no-console */
import webpack from 'webpack';
import webpackConfig from '../webpack.config.babel';
import colors from 'colors';

process.env.NODE_ENV = 'production';

webpack(webpackConfig).run((err, stats) => {
if (err) {
console.log(err.bold.red);
return 1;
}

const jsonStats = stats.toJson();

if (jsonStats.hasErrors) {
return jsonStats.errors.map(error => console.log(error.red));
}

if (jsonStats.hasWarnings) {
console.log('Webpack generated the following warnings: '.bold.yellow);
jsonStats.warnings.map(warning => console.log(warning.yellow));
}

console.log(`${'Webpack stats'.bold.magenta}\n${stats.toString({
children: false,
chunks: false, // Makes the build much quieter
colors: true, // Shows colors in the console
modules: false
})}\n`
);
console.log('Your app has been compiled in production mode and written to /dist');

return 0;
});
65 changes: 65 additions & 0 deletions webpack.config.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import webpack from 'webpack';
import path from 'path';
import ExtractTextPlugin from 'extract-text-webpack-plugin';

export default {
stats: 'errors-only',
devtool: 'source-map',
entry: [ "babel-polyfill", path.resolve(__dirname, 'src/index') ],
target: 'web',
output: {
path: __dirname + '/dist',
publicPath: '/',
filename: 'bundle.js'
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new ExtractTextPlugin('style.css'),
//new webpack.optimize.UglifyJsPlugin()
],
module: {
rules: [
{
test: /\.csp$/,
exclude: /node_modules/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
}
]
},

{
test: /\.js$/,
exclude: /node_modules/,
include: path.join(__dirname, 'src'),
use: [
{
loader: 'babel-loader',
options: {
presets: ['react', 'env', 'stage-1'],
plugins: [[ "import", { "libraryName": "antd", "style": "css" }]]
}
}
]
},

{
test: /(\.css)$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})
},

{test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, use: [ 'file-loader' ]},
{test: /\.(woff|woff2)$/, use: 'url-loader?prefix=font/&limit=5000'},
{test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, use: 'url-loader?limit=10000&mimetype=application/octet-stream'},
{test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, use: 'url-loader?limit=10000&mimetype=image/svg+xml'},
{test: /\.png$/, exclude: /node_modules/, use: 'file-loader?name=images/[name].[ext]'}
]
}
};

0 comments on commit 944dcdd

Please sign in to comment.