-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 32aa34d
Showing
11 changed files
with
275 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- 6.0.0 | ||
|
||
cache: | ||
directories: | ||
- node_modules | ||
|
||
script: | ||
- npm run build:dev | ||
- npm run build | ||
|
||
sudo: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Davy Duperron | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# buble-react-rollup-starter [![Build Status](https://travis-ci.org/yamafaktory/buble-react-rollup-starter.svg?branch=master)](https://travis-ci.org/yamafaktory/buble-react-rollup-starter) [![npm version](https://img.shields.io/npm/v/buble-react-rollup-starter.svg?style=flat)](https://www.npmjs.com/package/buble-react-rollup-starter) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) | ||
|
||
> A simple starter project to build cool [React](https://facebook.github.io/react/) applications with [Bublé](https://buble.surge.sh/guide/) and [Rollup](http://rollupjs.org/). | ||
The aim of this project is to provide a simple boilerplate to get started with React bundled as an ES2015 module via Rollup, compiled by Bublé. | ||
|
||
To sum up and give an overview of what can be achieved like a breath of fresh air: | ||
|
||
```JavaScript | ||
// Import React, ReactDOM and the component. | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
import { DummyComponent } from './components/dummy-component.js' | ||
|
||
// Define the root element and instantiate the DummyComponent. | ||
const root = document.querySelector('main') | ||
const dummyComponent = React.createElement(DummyComponent) | ||
|
||
// Append the DummyComponent instance to the root element. | ||
ReactDOM.render(dummyComponent, root) | ||
``` | ||
|
||
Rollup will magically includes only what you need in your bundle depending on the imports! | ||
|
||
Please not that this starter project [doesn't use JSX templates which are not currently handled by Bublé](https://gitlab.com/Rich-Harris/buble/issues/26). If you really want JSX to be part of your workflow, please give [babel-react-rollup-starter](https://github.com/yamafaktory/babel-react-rollup-starter) a try! | ||
|
||
## Prerequisite | ||
|
||
### NodeJS | ||
|
||
The easiest way to go is to use [nvm](https://github.com/creationix/nvm) and to install one of the recent NodeJS versions bundled with npm 3 by default (i.e. *NodeJS >= 5.0.0*). | ||
|
||
## Installation | ||
|
||
Clone this repository. | ||
|
||
```bash | ||
git clone https://github.com/yamafaktory/buble-react-rollup-starter | ||
cd buble-react-rollup-starter | ||
npm i | ||
``` | ||
|
||
Or even better, use *npm*! | ||
|
||
```bash | ||
npm i buble-react-rollup-starter | ||
``` | ||
|
||
## Usage | ||
|
||
### Development | ||
|
||
A basic workflow involving [Browsersync](https://www.browsersync.io/) is already implemented. Running the following command will open your default browser pointing to the `html/index-dev.html` file. Any modification of one of the files included in the *src* directory will trigger a new development build and refresh your browser: | ||
|
||
```bash | ||
npm test | ||
``` | ||
|
||
You can also generate a development build by running the following command: | ||
|
||
```bash | ||
npm run build:dev | ||
``` | ||
|
||
### Production | ||
|
||
First run the following command: | ||
|
||
```bash | ||
npm run build | ||
``` | ||
|
||
Then open the `html/index.html` file in your browser. | ||
|
||
The Rollup production configuration file switch the NodeJS environment to production and minify the code with [UglifyJS](http://lisperator.net/uglifyjs/). | ||
|
||
## Linting | ||
|
||
The code quality is checked by the [JavaScript Standard Style](http://standardjs.com/). | ||
|
||
## License | ||
|
||
Released under the [MIT license](https://opensource.org/licenses/MIT) by Davy Duperron. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Rollup plugins. | ||
import buble from 'rollup-plugin-buble' | ||
import cjs from 'rollup-plugin-commonjs' | ||
import globals from 'rollup-plugin-node-globals' | ||
import npm from 'rollup-plugin-npm' | ||
import replace from 'rollup-plugin-replace' | ||
import resolve from 'rollup-plugin-node-resolve' | ||
|
||
export default { | ||
dest: 'build/app.js', | ||
entry: 'src/index.js', | ||
format: 'iife', | ||
plugins: [ | ||
buble(), | ||
cjs({ | ||
exclude: 'node_modules/process-es6/**', | ||
include: [ | ||
'node_modules/fbjs/**', | ||
'node_modules/object-assign/**', | ||
'node_modules/react/**', | ||
'node_modules/react-dom/**' | ||
] | ||
}), | ||
globals(), | ||
npm({ main: true }), | ||
replace({ 'process.env.NODE_ENV': JSON.stringify('development') }), | ||
resolve({ browser: true }) | ||
], | ||
sourceMap: true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Rollup plugins. | ||
import replace from 'rollup-plugin-replace' | ||
import uglify from 'rollup-plugin-uglify' | ||
|
||
// Import the development configuration. | ||
import config from './dev' | ||
|
||
// Inject the production settings. | ||
config.dest = 'build/app.min.js' | ||
config.plugins[4] = replace({ 'process.env.NODE_ENV': JSON.stringify('production') }) | ||
config.plugins.push(uglify()) | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" | ||
content="width=device-width, initial-scale=1.0"> | ||
<title>babel-react-rollup-starter</title> | ||
</head> | ||
<body> | ||
<main></main> | ||
<script src="build/app.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" | ||
content="width=device-width, initial-scale=1.0"> | ||
<title>babel-react-rollup-starter</title> | ||
</head> | ||
<body> | ||
<main></main> | ||
<script src="../build/app.min.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"name": "buble-react-rollup-starter", | ||
"version": "1.0.0", | ||
"title": "buble-react-rollup-starter", | ||
"description": "A simple starter project to build cool React applications with Bublé and Rollup.", | ||
"keywords": [ | ||
"Bublé", | ||
"Browsersync", | ||
"React", | ||
"Rollup", | ||
"StandardJS" | ||
], | ||
"homepage": "https://github.com/yamafaktory/buble-react-rollup-starter", | ||
"author": { | ||
"name": "Davy Duperron", | ||
"url": "https://github.com/yamafaktory" | ||
}, | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/yamafaktory/buble-react-rollup-starter" | ||
}, | ||
"engines": { | ||
"npm": ">=3.0.0", | ||
"node": ">=5.0.0" | ||
}, | ||
"dependencies": { | ||
"react": "15.0.2", | ||
"react-dom": "15.0.2" | ||
}, | ||
"devDependencies": { | ||
"buble": "0.8.4", | ||
"browser-sync": "2.12.5", | ||
"npm-run-all": "1.6.0", | ||
"onchange": "2.2.0", | ||
"rollup": "0.26.3", | ||
"rollup-plugin-buble": "0.8.0", | ||
"rollup-plugin-commonjs": "2.2.1", | ||
"rollup-plugin-node-globals": "1.0.5", | ||
"rollup-plugin-node-resolve": "1.5.0", | ||
"rollup-plugin-npm": "1.4.0", | ||
"rollup-plugin-replace": "1.1.0", | ||
"rollup-plugin-uglify": "0.3.1", | ||
"snazzy": "3.0.1", | ||
"standard": "6.0.8" | ||
}, | ||
"scripts": { | ||
"prebuild": "npm run std", | ||
"build": "rollup -c config/prod.js", | ||
"build:dev": "rollup -c config/dev.js", | ||
"browse": "browser-sync start --s --index 'html/index-dev.html' --files 'html/**/*.html, build/**/*.js' --no-notify", | ||
"std": "standard --verbose | snazzy", | ||
"test": "npm-run-all --parallel watch browse", | ||
"watch": "onchange src -- npm run build:dev", | ||
"preversion": "git pull && npm up && npm run std", | ||
"version": "npm run build && git add -A .", | ||
"postversion": "git push --tags origin HEAD" | ||
}, | ||
"standard": { | ||
"ignore": [ | ||
"build" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Import React. | ||
import React from 'react' | ||
|
||
// Create the elements. | ||
const title = React.createElement('h1', { key: 'title' }, 'Hi from DummyComponent.') | ||
const content = React.createElement('em', { key: 'content' }, 'Now let\'s play with React!') | ||
const article = React.createElement('article', null, [title, content]) | ||
|
||
export class DummyComponent extends React.Component { | ||
render () { return article } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Import React, ReactDOM and the component. | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
import { DummyComponent } from './components/dummy-component.js' | ||
|
||
// Define the root element and instantiate the DummyComponent. | ||
const root = document.querySelector('main') | ||
const dummyComponent = React.createElement(DummyComponent) | ||
|
||
// Append the DummyComponent instance to the root element. | ||
ReactDOM.render(dummyComponent, root) |