Skip to content

Commit

Permalink
initial commit for spec testing
Browse files Browse the repository at this point in the history
  • Loading branch information
roylee0704 committed Nov 29, 2015
1 parent bf9bf77 commit 456b784
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 0 deletions.
33 changes: 33 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const path = require('path');
const express = require('express');
const webpack = require('webpack');
const config = require('./webpack.config.development');
const port = 8080;

const app = express();
const compiler = webpack(config);


app.use(require('webpack-dev-middleware')(compiler, {
publicPath: config.output.publicPath,
stats: {
colors: true
}
}));

app.use(require('webpack-hot-middleware')(compiler));

app.get('*', (req, resp) => {
resp.sendFile(path.join(__dirname, './spec/index.html'));
});

app.listen(port, '0.0.0.0', (err) => {
if (err) {
console.log(err);
return;
}

console.log(path.join(__dirname, './spec/index.html'));

console.log('Listening at http://0.0.0.0:' + port);
});
13 changes: 13 additions & 0 deletions spec/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link href='https://fonts.googleapis.com/css?family=Roboto:400,300,500' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/build/spec.css">
</head>
<body>
<div id="flexboxgrid-test"></div>
<script src="/build/spec.js"></script>
</body>
</html>
5 changes: 5 additions & 0 deletions spec/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Root from './root';

ReactDOM.render(<Root />, document.getElementById('flexboxgrid-test'));
12 changes: 12 additions & 0 deletions spec/root.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* global VERSION */
require('./style');

import React from 'react';
import {Grid} from '../src/index';

const Root = () => (
<Grid>Hello World, Roy Lee</Grid>
);


export default Root;
7 changes: 7 additions & 0 deletions spec/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
html {
font-family: 'Roboto', sans-serif
}

body, h1, h2, h3, h4, h5, h6 {
margin: 0
}
45 changes: 45 additions & 0 deletions webpack.config.development.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const pkg = require('./package');
const webpack = require('webpack');
const path = require('path');
const autoprefixer = require('autoprefixer');
const ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
context: __dirname,
devtool: 'inline-source-map',
entry: [
'webpack-hot-middleware/client',
'./spec/index.js'
],
output: {
path: path.join(__dirname, 'build'),
publicPath: '/build/',
filename: 'spec.js'
},
resolve: {
extensions: ['', '.js', '.scss', '.json']
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /(node_modules)/,
loader: 'babel'
},
{
test: /(\.scss|\.css)$/,
loader: ExtractTextPlugin.extract('style-loader', 'css?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass?sourceMap')
}
]
},
postcss: [autoprefixer],
plugins: [
new ExtractTextPlugin('spec.css', {allChunks: true}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development'),
VERSION: JSON.stringify(pkg.version)
})
]
};

0 comments on commit 456b784

Please sign in to comment.