Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidprogrammer committed May 29, 2016
1 parent 1334910 commit b7eec35
Show file tree
Hide file tree
Showing 77 changed files with 281 additions and 62 deletions.
13 changes: 0 additions & 13 deletions .editorconfig

This file was deleted.

45 changes: 11 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,19 @@
## A Sample Blog App Written in Mantra
What can you do with repo?

This is a sample blog app written in [Mantra](https://github.com/kadirahq/mantra) covering core features of it.
You can run the client part of the meteor application separately (building with webpack), with or without the server running.(you need the server to be run at least once though, after that, the server could be anywhere). There is no major code changes to the original mantra-sample-blog-app. (So there is no new learning involved)

### Setting Up

* Clone this repo
* Do `npm install` to install dependencies
* Make sure you've installed Meteor locally

### Running The App

Simply start your app with `meteor -p 5005`.
Then you can access the app on <http://localhost:5005>

### Running Tests

In this app, every part of the client side is fully tested using the familiar tools like Mocha, Chai and Sinon.

Run tests with:

```
npm test
```
cd server
meteor
**See package.json for more information about testing setup.**
cd client
npm install
npm start
### Running Storybook
This app is setup for [React Storybook](https://github.com/kadirahq/react-storybook). Run following command to start the React Storybook:

```
npm run storybook
```
You can go to localhost:8080 to see your app.

> **NOTE:** If this gives you missing module errors, React Storybook requires npm v3. Here's how to install npm3 and get it setup.
> ```js
> npm install -g npm@3.8.5
> rm -rf node_modules
> npm install
> npm run storybook
> ```
--TODO
-wallaby.js / mocha etc may need modifications.
-will update them in due course in the sample
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## A Sample Blog App Written in Mantra

This is a sample blog app written in [Mantra](https://github.com/kadirahq/mantra) covering core features of it.

### Setting Up

* Clone this repo
* Do `npm install` to install dependencies
* Make sure you've installed Meteor locally

### Running The App

Simply start your app with `meteor -p 5005`.
Then you can access the app on <http://localhost:5005>

### Running Tests

In this app, every part of the client side is fully tested using the familiar tools like Mocha, Chai and Sinon.

Run tests with:

```
npm test
```

**See package.json for more information about testing setup.**

### Running Storybook

This app is setup for [React Storybook](https://github.com/kadirahq/react-storybook). Run following command to start the React Storybook:

```
npm run storybook
```

> **NOTE:** If this gives you missing module errors, React Storybook requires npm v3. Here's how to install npm3 and get it setup.
> ```js
> npm install -g npm@3.8.5
> rm -rf node_modules
> npm install
> npm run storybook
> ```
52 changes: 52 additions & 0 deletions client/devServer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env node
var WebpackDevServer = require("webpack-dev-server");
var HtmlWebpackPlugin = require('html-webpack-plugin');
// -d --hot --inline --content-base build/

// If you are not using html-webpack-plugin use an index.html like the following in the build directory
// <html>
// <head>
// <meta charset="utf-8">
// <link rel="stylesheet" href="style.css">
// </head>
// <body>
// <script type="text/javascript" src="app.js" charset="utf-8"></script>
// <div id="root"></div>
// </body>
// </html>

var webpack = require("webpack");
var path = require('path');
var config = require("./webpack.config.js");
config.entry.app.unshift("webpack-dev-server/client?http://localhost:8080/", "webpack/hot/dev-server");
config.plugins.unshift(
new webpack.HotModuleReplacementPlugin()
,new HtmlWebpackPlugin()
);
// IF you are struggling with a difficult problem, uncomment the following, (increases build speed though)
config['devtool'] = 'source-map';
config['debug'] = true;
var request = require('request');
server = new WebpackDevServer(webpack(config), {
contentBase: config.output.path,
publicPath: config.output.publicPath,
historyApiFallback: true,
hot: true,
stats: {colors: true}
});
// https://github.com/reactjs/react-router/issues/676
server.app.use(function pushStateHook(req, res, next) {
var ext = path.extname(req.url);
if ((ext === '' || ext === '.html') && req.url !== '/') {
req.pipe(request(
// localURL
'http://localhost:8080'
)).pipe(res);
} else {
next();
}
});
server.listen(8080, "localhost", function() {});


// remove push state if not needed later
28 changes: 26 additions & 2 deletions package.json → client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"name": "mantra-demo",
"version": "0.4.0",
"scripts": {
"start": "npm run client",
"client": "node devServer.js",
"lint": "eslint ./lib ./client ./server --ext .js",
"lintfix": "npm run lint -- --fix",
"testonly": "mocha .scripts/mocha_boot.js client/**/tests/**/*.js --compilers js:babel-core/register",
Expand All @@ -11,23 +13,45 @@
},
"devDependencies": {
"@kadira/storybook": "^1.22.1",
"autoprefixer": "^6.3.6",
"babel-core": "6.x.x",
"babel-loader": "^6.2.4",
"babel-plugin-react-require": "2.x.x",
"babel-polyfill": "6.x.x",
"babel-preset-es2015": "6.x.x",
"babel-preset-react": "6.x.x",
"babel-preset-stage-2": "6.x.x",
"babel-root-slash-import": "1.x.x",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-react-transform": "^2.0.2",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-stage-0": "^6.5.0",
"chai": "3.x.x",
"css-loader": "^0.23.1",
"enzyme": "^2.2.0",
"expose-loader": "^0.7.1",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.5",
"html-loader": "^0.4.3",
"html-webpack-plugin": "^2.16.1",
"eslint": "1.10.x",
"eslint-plugin-react": "3.15.x",
"jsdom": "^8.0.4",
"meteor-imports-webpack-plugin": "lucidprogrammer/meteor-imports-webpack-plugin",
"mocha": "2.x.x",
"node-libs-browser": "^1.0.0",
"node-sass": "^3.6.0",
"postcss-loader": "^0.9.1",
"react-addons-test-utils": "^15.0.2",
"react-hot-loader": "^1.3.0",
"sass-loader": "^3.2.0",
"raw-loader": "^0.5.1",
"react-addons-test-utils": "^15.0.0",
"sinon": "1.17.x",
"style-loader": "^0.13.1"
"strip-loader": "^0.1.2",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.13.0",
"webpack-dev-server": "^1.14.1"
},
"dependencies": {
"domready": "^1.0.8",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Collections from '/lib/collections';
import * as Collections from '../../../server/lib/collections';
import {Meteor} from 'meteor/meteor';
import {FlowRouter} from 'meteor/kadira:flow-router';
import {ReactiveDict} from 'meteor/reactive-dict';
Expand Down
5 changes: 5 additions & 0 deletions client/src/globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'meteor-imports';
import {Meteor} from 'meteor/meteor';
import {Tracker} from 'meteor/tracker';
global.Meteor = Meteor;
global.Tracker = Tracker;
2 changes: 2 additions & 0 deletions client/main.js → client/src/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'meteor-imports';

import {createApp} from 'mantra-core';
import initContext from './configs/context';

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions client/webpack-production.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var WebpackStrip = require('strip-loader');
var path = require('path');
var devConfig = require('./webpack.config.js');
var stripLoader = {
"test": [/.js$/,/.jsx$/],
"include":[
path.resolve(__dirname, "entry"),
path.resolve(__dirname, "../server/imports/common")
],
"loader":WebpackStrip.loader('console.log','debug')
};
devConfig.module.loaders.push(stripLoader);
module.exports = devConfig;

// TODO
// production bundle warning React
// http://dev.topheman.com/make-your-react-production-minified-version-with-webpack/
122 changes: 122 additions & 0 deletions client/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
var path = require('path');
// var webpack = require("webpack");
// This loads the meteor client files from .meteor/local so that it can be used in client applications
// without running meteor or needing the meteor context
var MeteorImportsPlugin = require('meteor-imports-webpack-plugin');
// we will create a separate bundle for css
var ExtractTextPlugin = require('extract-text-webpack-plugin');
//Automatically prefix vendor prefixes to CSS
var autoprefixer = require('autoprefixer');

module.exports = {
"entry" : {"app":['./src/main.js','./src/globals.js']},
"output": {
"path": path.resolve('./build'),
"publicPath" :"/",
"filename": '[name].js'
},
"externals": [],
"plugins": [
new MeteorImportsPlugin({
ROOT_URL: 'http://localhost:3000/',
DDP_DEFAULT_CONNECTION_URL: 'http://localhost:3000/',
PUBLIC_SETTINGS: {},
meteorFolder: '../server',
meteorEnv: {
NODE_ENV: 'development'
},
exclude: ['ecmascript']
}),
new ExtractTextPlugin('style.css')
],
"module": {
"noParse": [/libphonenumber.js$/],
// "preLoaders" : [{
// "test": [/.js$/,/.jsx$/],
// "include":[
// path.resolve(__dirname, "entry")
// // ,
// // path.resolve(__dirname, "../server/imports/common")
// ],
// "loader":"jshint-loader"
// }],
"loaders": [{
"test": require.resolve("react"),
"loader": "expose-loader?React"
}, {
"test": /\.(js|jsx)$/,
"loader": require.resolve("babel-loader"),
"include": [path.resolve(__dirname, "src"), path.resolve(__dirname, "../server/lib")],
"query": {
"presets": [
require.resolve("babel-preset-es2015"),
require.resolve("babel-preset-stage-2"),
require.resolve("babel-preset-stage-0"),
require.resolve("babel-preset-react")
],
"plugins": [
require.resolve("babel-plugin-react-require"),
require.resolve("babel-root-slash-import"),
require.resolve("babel-plugin-transform-decorators-legacy"),
require.resolve("babel-plugin-add-module-exports")
],
"compact": false
}
}, {
"test": /\.css$/,
"exclude":/react-select/,
"loader": ExtractTextPlugin.extract("style-loader", "css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss-loader")
},
// Global CSS
// regular 'global' css or pre-compiled.
// as of now, only react-select needs this
{
"test": /\.css$/,
"include":/react-select/,
"loader": ExtractTextPlugin.extract("style-loader", "css-loader!postcss-loader")
},

{
"test": /\.scss$/,
"exclude":/node_modules/,
"loader": ExtractTextPlugin.extract("style-loader","css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss-loader!sass-loader")
}, {
"test": /\.html$/,
"exclude":/node_modules/,
"loader": "html"
}, {
"test": /\.json$/,
"include": [path.resolve(__dirname, "entry"), path.resolve(__dirname, "../server/imports/common")],
"loader": require.resolve("json-loader")
}, {
"test": /\.(png|jpg|ttf|svg)$/,
"exclude":/node_modules/,
// base64 encode the image and inline if size is less than the limit
"loader": "url-loader?limit=8182"
}, {
"test": /\.eot/,
"loader": 'url-loader?limit=8182&mimetype=application/vnd.ms-fontobject'
}, {
"test": /\.woff2(\?\S*)?$/,
"loader": 'url-loader?limit=8182&mimetype=application/font-woff2'
}, {
"test": /\.woff/,
"loader": 'url-loader?limit=8182&mimetype=application/font-woff'
}, {
"test": /\.ttf/,
"loader": 'url-loader?limit=8182&mimetype=application/font-ttf'
}]
},
//Automatically resove, import 'abc' [abc can be jsx or js], not allowing for json, css, scsss etc
"resolve": {
"extensions": ["", ".js", ".jsx"]
},
"postcss": function() {
return {
"defaults": [
autoprefixer({"browsers": ["last 2 versions"]})
]
};
}

}
1 change: 0 additions & 1 deletion public/placeholder.txt

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit b7eec35

Please sign in to comment.