Giter Site home page Giter Site logo

barbar / vortigern Goto Github PK

View Code? Open in Web Editor NEW
641.0 36.0 128.0 2 MB

A universal boilerplate for building web applications w/ TypeScript, React, Redux, Server Side Rendering and more.

Home Page: https://barbar.github.io/vortigern

License: MIT License

JavaScript 40.64% TypeScript 58.53% CSS 0.83%
redux react typescript boilerplate webpack universal isomorphic vortigern

vortigern's Introduction

Vortigern

Build Status Dependency Status devDependency Status Code Climate GitHub issues GitHub license


Vortigern is our opinionated boilerplate for crafting universal web applications by using modern technologies like TypeScript, React and Redux.

TypeScript React Redux

Libraries

Vortigern uses the following libraries and tools:

Core

Utilities

Build System

Dev & Prod Server

Developer Experience

Testing

Directory Structure

.
├── build                       # Built, ready to serve app.
├── config                      # Root folder for configurations.
│   ├── test                    # Test configurations.
│   ├── types                   # Global type definitions, written by us.
│   ├── webpack                 # Webpack configurations.
│   └── main.ts                 # Generic App configurations.
├── node_modules                # Node Packages.
├── src                         # Source code.
│   ├── app                     # App folder.
│   │ ├── components            # React Components.
│   │ ├── containers            # React/Redux Containers.
│   │ ├── helpers               # Helper Functions & Components.
│   │ ├── redux                 # Redux related code aka data layer of the app.
│   │ │   ├── modules           # Redux modules.   
│   │ │   ├── reducers.ts       # Main reducers file to combine them.  
│   │ │   └── store.ts          # Redux store, contains global app state.    
│   │ └── routes.tsx            # Routes.
│   ├── client.tsx              # Entry point for client side rendering.
│   └── server.tsx              # Entry point for server side rendering.
├── typings                     # Type definitions installed with typings.              
├── .dockerignore               # Tells docker which files to ignore.
├── .gitignore                  # Tells git which files to ignore.
├── .stylelintrc                # Configures stylelint.
├── Dockerfile                  # Dockerfile.
├── favicon.ico                 # Favicon.
├── package.json                # Package configuration.
├── README.md                   # This file
├── tsconfig.json               # TypeScript transpiler configuration.
├── tslint.json                 # Configures tslint.
└── typings.json                # Typings package configuration.

Installation

You can clone from this repository or install the latest version as a zip file or a tarball.

$ git clone https://github.com/barbar/vortigern
$ cd vortigern
$ npm install

Usage

All commands defaults to development environment. You can set NODE_ENV to production or use the shortcuts below.

# Running

$ npm start # This starts the app in development mode

# Starting it with the production build
$ NODE_ENV=production npm start # or
$ npm run start:prod

# Building 

$ npm build # This builds the app in development mode

# Commands below builds the production build
$ NODE_ENV=production npm build # or
$ npm run build:prod

# Testing
$ npm test

For Windows users, we recommend using the shortcuts instead of setting environment variables because they work a little different on Windows.

Notes

# If you want install additional libraries, you can also install their typings from DefinitelyTyped
$ typings install dt~<package> --global --save
# or if it's located on npm
$ typings install <package> --save

Credits

Vortigern is released under the MIT license.

The image in this README belongs to hhvferry.com.


We help startups start and stay started by helping them plan, strategize, fund and execute their vision.

You can contact us at [email protected]

Be sure to check out available jobs at Barbar.

vortigern's People

Contributors

alexandr-bbm avatar altaywtf avatar angularsen avatar ardani avatar arnarp avatar batuhan avatar bherila avatar btomala avatar cedmax avatar dmitry-korolev avatar eputtone avatar felix93 avatar jagielskip avatar lavatoaster avatar liukun avatar matb avatar patroza avatar pedropovedaq avatar psrebniak avatar rjmunro avatar ufukomer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vortigern's Issues

no such file or directory, stat 'favicon.ico'

when running npm run build:prod and trying to run the server.js file inside the build folder i get this message:

Error: ENOENT: no such file or directory, stat '/Users/username/projects/vortigern/build/favicon.ico' at Error (native) at Object.fs.statSync (fs.js:892:18) at favicon (/Users/username/projects/vortigern/node_modules/serve-favicon/index.js:64:15) at Object.module.exports.config.env (/Users/username/projects/vortigern/build/server.js:97:10) at __webpack_require__ (/Users/username/projects/vortigern/build/server.js:21:30) at module.exports.Object.assign.i (/Users/username/projects/vortigern/build/server.js:41:18) at Object.<anonymous> (/Users/username/projects/vortigern/build/server.js:44:10) at Module._compile (module.js:425:26) at Object.Module._extensions..js (module.js:432:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:313:12) at Function.Module.runMain (module.js:457:10) at startup (node.js:138:18) at node.js:974:3

Hot reload on server side

Hi I'll start by saying great starter kit! I'm really liking the Typescript. I've got this running on my dev machine and I'm trying to do a hot module replacement. It looks like the code is updated automatically on the client side, but the node server is not updated.

As a test, I edited Home/index.tsx and replaced "Hello" with "Hello2!", and then saved the file. At this point webpack builds and the browser is updated through HMR.

[HMR] connected
client.js:127 [HMR] bundle rebuilding
client.js:130 [HMR] bundle rebuilt in 2495ms
process-update.js:27 [HMR] Checking for updates on the server...
process-update.js:100 [HMR] Updated modules:
process-update.js:102 [HMR]  - ./src/app/containers/Home/index.tsx
process-update.js:107 [HMR] App is up to date.

When I refresh the page to trigger a server-side rendering I get the following error message:

warning.js:44 Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:
 (client) a-reactid="15">Hello2!</p></div></sectio
 (server) a-reactid="15">Hello!</p></div></section

It appears that the server has the older version of the file. The only way I found to update it is by restarting the server. Does hot reloading on the server side work for other people? If so, it might be something wrong about my system configuration that I should investigate. If this is not supported, should we consider adding it?

npm start failed under windows

under pure windows w/o cygwin installed npm start is failed in package.json->scripts->clean, there is "clean": "rm -rf build/"

Error building on first try

I just cloned the repo. I ran npm install and it installed all the dependencies successfully. However when I ran npm start, it throws the following error:

-- /build/server.js:70 --
var manifest = webpack_require(!(function webpackMissingModule() { var e = new Error("Cannot find module "../build/manifest.json""); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
Error: Cannot find module "../build/manifest.json"

It looks like the manifest.json file isn't being created in the build folder.

Do you guys think I might I messed up while cloning, or missed a step?

Thanks.

Why not CSS Preprocessor?

Any reason not to use SCSS (or even LESS if you want)?

Sass SCSS seems to be the popular choice of CSS preprocessing in React projects.

add style linter

only for styles written within the app directory, otherwise we may have to deal with vendor css problems.

write wiki

background url(./barbar.png) doesn't work

When using background image in CSS, e.g:

.home {
    text-align: center;
    background: url('./barbar.png')
}

the compiled CSS seems to resolve the asset fine, however the browser is trying to load it relatively to the blob:// css file which was injected to the HEAD causing an incorrect host name by Chrome

Isomorphic style loader

I'm noticing a flicker on the screen when loading a new page with caching disabled. I think it's because when the server side renders the page it does not include styles. Eventually, when the styles are downloaded the elements are repositioned to their correct locations. It would be better to include the styles with the server side rendering so there is no flicker.

I found a package that appears to solve this problem called isomorphic-style-loader. It appears to be a replacement for style-loader. https://github.com/kriasoft/isomorphic-style-loader. Would people be open to this upgrade?

npm start / npm run start fails due to NODE_ENV not found

Hello,
I wanted to give vortgern a try and did the following:

$ git clone https://github.com/barbar/vortigern
$ cd vortigern
$ npm run setup

everything worked so far.

Now I am getting an error when trying to start it:

$ npm start

Here is a screenshot of the console output:
image

I am using windows 10.
My node version is V4.4.3
My npm version is 3.8.2

I couldn't find anything on google regarding my issue. I hope you can help me. Thanks!

Cheers,
Raphael Hippe

Including example of .jsx component

When writing applications it is often that you find code that is written in JavaScript instead of Typescript.

Would it be possible to include an example component written in plain JavaScript? I tried this with a component as follows:

src/app/components/MyComponent/MyComponent.jsx:

import * as React from 'react';

class MyComponent extends React.Component {
    constructor(props) {
        super(props);
    }

    render() {
        return (
            <h1>Hello from MyComponent</h1>
        );
    }
}

export { MyComponent };

and included it in the file src/app/components/index.tsx as follows:

export { Header } from './Header/Header';
export {MyComponent } from './MyComponent/MyComponent';

But i keep getting the error:

ERROR in ./src/app/components/index.tsx
(2,28): error TS2307: Cannot find module './MyComponent/MyComponent'.

Another thing is using existing ReactJS libraries, like https://onsen.io/v2/react.html. How we leverage these existing libraries without writing type definition files?

server-side rendering / client-side rendering out of sync

I'm getting the following error:

warning.js:44 Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:
 (client) om MyComponent</h1><ons-button data-reac
 (server) om MyComponent</h1></div></section>

It is clear that what is rendered at server side is not equal to what was rendered at client side.

What I did was including an existing ReactJS component library called react-onsenui (see https://onsen.io/v2/react.html).

I added to both the client.tsx file and the server.tsx file the following lines:

require('onsenui/css/onsenui.css');
require('onsenui/css/onsen-css-components.css');
require('onsenui');

and in the Home.tsx container I did:

import * as React from 'react';
const s = require('./style.css');

const Button = require('react-onsenui').Button;

class Home extends React.Component<any, any> {
  constructor(props) {
    super(props);
    this.handleButtonClick = this.handleButtonClick.bind(this);
  }

  handleButtonClick() {
    console.log("CLICKED");
  }

  render() {
    return (
      <div className={s.home}>
        <img src={require('./barbar.png')} />
        <p>Hello world!</p>
        <Button onClick={this.handleButtonClick}>MY BUTTON</Button>
      </div>
    );
  }
}
export { Home }

What do I need to do to keep client and server rendering in sync?

support Electron (or not?)

I'll convert barbar/riothamus to TypeScript and couldn't decide if I should push the Electron-specific edits back to Vortigern or fork Vortigern to create another boilerplate for Electron.

Any ideas?

nested css classes disappear after running npm run build:prod

I use nested classes in some of my css files like this:

.foo { & .nested {} }

and in the tsx file i use it like this:

`const s = require('./style.css');

div className={s.nested}
`

it runs smoothly in dev mode, but all of these classes disappear from the css after the build

add unit tests for components

Hi @altayaydemir,

What about the unit test for every component. I have seen the test structure prepared for ts but not seen for every component-specific ones.

Thanks.

Keep cool.

Time to discuss again: common repo

Including the internal project we are doing right now, upcoming vortigen-basic , vortigern-electron and Simpleserver/Riathamus, we'll have 5 TypeScript + React projects.

Is it time to pack common files in to a repository and publish it as a package?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.