1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-01 00:08:27 +01:00

Setup react, webpack, babel, hmr etc #153

This commit is contained in:
Ivar 2016-09-11 21:54:31 +02:00
parent 397e848e26
commit dcdd5ac31d
9 changed files with 178 additions and 0 deletions

View File

@ -0,0 +1,8 @@
{
"presets": ["react", "es2015", "stage-0"],
"env": {
"development": {
"presets": ["react-hmre"]
}
}
}

View File

@ -0,0 +1,6 @@
{
"extends": [
"finn",
"finn/node"
]
}

View File

@ -0,0 +1,11 @@
<!doctype html>
<html>
<head>
<title>Sample App</title>
</head>
<body>
<div id='root'>
</div>
<script src="/static/bundle.js"></script>
</body>
</html>

View File

@ -0,0 +1,9 @@
// preprocessor.js
'use strict';
const ReactTools = require('react-tools');
module.exports = {
process (src) {
return ReactTools.transform(src);
},
};

View File

@ -0,0 +1,64 @@
{
"name": "unleash-frontend",
"description": "unleash your features",
"version": "1.0.0-alpha.2",
"keywords": [
"unleash",
"feature toggle",
"feature",
"toggle"
],
"files": [
"public"
],
"repository": {
"type": "git",
"url": "ssh://git@github.com:finn-no/unleash.git"
},
"bugs": {
"url": "https://github.com/finn-no/unleash/issues"
},
"engines": {
"node": "6"
},
"scripts": {
"build": "webpack -p",
"start": "NODE_ENV=development node server",
"hot-dev-server": "webpack-dev-server --config webpack-hot-dev-server.config.js --hot --progress --colors --port 3000 --inline",
"test": "jest",
"test:ci": "npm run test"
},
"main": "./lib/index.js",
"dependencies": {
"react": "^15.3.1",
"react-dom": "^15.3.1",
"react-router": "^2.8.0"
},
"devDependencies": {
"babel-core": "^6.14.0",
"babel-loader": "^6.2.5",
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.11.1",
"babel-preset-react-hmre": "^1.1.1",
"babel-preset-stage-0": "^6.5.0",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.15.1"
},
"jest": {
"scriptPreprocessor": "<rootDir>/jest-preprocessor.js",
"modulePathIgnorePatterns": [
"<rootDir>/node_modules/npm"
],
"unmockedModulePathPatterns": [
"<rootDir>/node_modules/react",
"<rootDir>/node_modules/reflux"
],
"moduleFileExtensions": [
"jsx",
"js"
]
},
"pre-commit": [
"lint"
]
}

View File

@ -0,0 +1,16 @@
'use strict';
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const config = require('./webpack.config');
new WebpackDevServer(webpack(config), {
colors: true,
publicPath: config.output.publicPath,
hot: true,
historyApiFallback: true,
}).listen(3000, 'localhost', (err) => {
if (err) {
return console.log(err);
}
console.log('Listening at http://localhost:3000/');
});

View File

@ -0,0 +1,9 @@
import React, { Component } from 'react';
export default class App extends Component {
render() {
return (
<h1>Hello, world</h1>
);
}
}

View File

@ -0,0 +1,7 @@
'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(<App />, document.getElementById('root'));

View File

@ -0,0 +1,48 @@
// docs: http://webpack.github.io/docs/configuration.html
'use strict';
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'./src/index',
],
resolve: {
root: [path.join(__dirname, 'src')],
extensions: ['', '.js', '.jsx'],
modulesDirectories: ['web_modules', 'node_modules'],
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/static/',
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ['babel'],
include: path.join(__dirname, 'src'),
},
],
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
],
devtool: 'source-map',
externals: {
// stuff not in node_modules can be resolved here.
},
};