mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-06 00:07:44 +01:00
Setup react, webpack, babel, hmr etc #153
This commit is contained in:
parent
397e848e26
commit
dcdd5ac31d
8
packages/unleash-frontend-next/.babelrc
Normal file
8
packages/unleash-frontend-next/.babelrc
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"presets": ["react", "es2015", "stage-0"],
|
||||||
|
"env": {
|
||||||
|
"development": {
|
||||||
|
"presets": ["react-hmre"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
6
packages/unleash-frontend-next/.eslintrc
Normal file
6
packages/unleash-frontend-next/.eslintrc
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"finn",
|
||||||
|
"finn/node"
|
||||||
|
]
|
||||||
|
}
|
11
packages/unleash-frontend-next/index.html
Normal file
11
packages/unleash-frontend-next/index.html
Normal 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>
|
9
packages/unleash-frontend-next/jest-preprocessor.js
Normal file
9
packages/unleash-frontend-next/jest-preprocessor.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// preprocessor.js
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const ReactTools = require('react-tools');
|
||||||
|
module.exports = {
|
||||||
|
process (src) {
|
||||||
|
return ReactTools.transform(src);
|
||||||
|
},
|
||||||
|
};
|
64
packages/unleash-frontend-next/package.json
Normal file
64
packages/unleash-frontend-next/package.json
Normal 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"
|
||||||
|
]
|
||||||
|
}
|
16
packages/unleash-frontend-next/server.js
Normal file
16
packages/unleash-frontend-next/server.js
Normal 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/');
|
||||||
|
});
|
9
packages/unleash-frontend-next/src/App.jsx
Normal file
9
packages/unleash-frontend-next/src/App.jsx
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
|
||||||
|
export default class App extends Component {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<h1>Hello, world</h1>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
7
packages/unleash-frontend-next/src/index.js
Normal file
7
packages/unleash-frontend-next/src/index.js
Normal 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'));
|
48
packages/unleash-frontend-next/webpack.config.js
Normal file
48
packages/unleash-frontend-next/webpack.config.js
Normal 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.
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user