From 6f4c654481e2d947a024e7080f0ab126fd3205ef Mon Sep 17 00:00:00 2001 From: sangbum Kim Date: Sun, 3 Apr 2016 02:53:21 +0900 Subject: [PATCH] added template file --- index.dev.html | 20 +++++ index.prod.html | 20 +++++ package.json | 60 +++++++++++++ server.js | 58 ++++++++++++ src/main/cjsx/components/App.cjsx | 25 ++++++ src/main/cjsx/components/Theme.cjsx | 23 +++++ src/main/cjsx/main.cjsx | 12 +++ src/main/scss/main.scss | 0 webpack.config.coffee | 135 ++++++++++++++++++++++++++++ webpack.prod.config.coffee | 131 +++++++++++++++++++++++++++ 10 files changed, 484 insertions(+) create mode 100644 index.dev.html create mode 100644 index.prod.html create mode 100644 package.json create mode 100644 server.js create mode 100644 src/main/cjsx/components/App.cjsx create mode 100644 src/main/cjsx/components/Theme.cjsx create mode 100644 src/main/cjsx/main.cjsx create mode 100644 src/main/scss/main.scss create mode 100644 webpack.config.coffee create mode 100644 webpack.prod.config.coffee diff --git a/index.dev.html b/index.dev.html new file mode 100644 index 0000000..69f258d --- /dev/null +++ b/index.dev.html @@ -0,0 +1,20 @@ + + + + + + + + + + + + Starter Template for Bootstrap + + + + +
APPLICATION CONTENT
+ + + diff --git a/index.prod.html b/index.prod.html new file mode 100644 index 0000000..4d15e0f --- /dev/null +++ b/index.prod.html @@ -0,0 +1,20 @@ + + + + + + + + + + + + Starter Template for Bootstrap + + + + + +
APPLICATION CONTENT
+ + diff --git a/package.json b/package.json new file mode 100644 index 0000000..d8000a6 --- /dev/null +++ b/package.json @@ -0,0 +1,60 @@ +{ + "private": true, + "dependencies": { + "consolelog": "^2.1.3", + "es5-shim": "^4.5.7", + "es6-shim": "^0.35.0", + "html5shiv": "^3.7.3", + "jquery": "^2.2.2", + "jquery.backstretch": "^2.1.13", + "json3": "^3.3.2", + "lodash": "^4.7.0", + "material-ui": "^0.15.0-alpha.2", + "normalize.css": "^4.0.0", + "react": "^0.14.8", + "react-dom": "^0.14.0", + "react-tap-event-plugin": "^0.2.2" + }, + "devDependencies": { + "autoprefixer": "^6.3.5", + "babel-core": "^6.7.4", + "babel-eslint": "^6.0.0", + "babel-loader": "^6.2.4", + "babel-plugin-transform-runtime": "^6.6.0", + "babel-polyfill": "^6.3.14", + "babel-preset-es2015": "^6.0.15", + "babel-preset-react": "^6.0.15", + "body-parser": "^1.15.0", + "bower-webpack-plugin": "^0.1.9", + "cjsx-loader": "^2.1.0", + "coffee-loader": "^0.7.2", + "coffee-script": "^1.10.0", + "css-loader": "^0.23.1", + "eslint": "^2.2.0", + "eslint-loader": "^1.0.0", + "eslint-plugin-react": "^4.0.0", + "express": "^4.13.4", + "extract-text-webpack-plugin": "^1.0.1", + "file-loader": "^0.8.5", + "html-loader": "^0.4.3", + "imports-loader": "^0.6.5", + "json-loader": "^0.5.4", + "markdown-loader": "^0.1.7", + "node-sass": "^3.4.2", + "postcss": "^5.0.11", + "postcss-loader": "^0.8.2", + "react-addons-test-utils": "^0.14.0", + "react-hot-loader": "^1.3.0", + "resolve-url-loader": "^1.4.3", + "sass-loader": "^3.2.0", + "style-loader": "^0.13.1", + "text-loader": "0.0.1", + "url-loader": "^0.5.7", + "webpack": "^1.12.14", + "webpack-dev-middleware": "^1.6.1", + "webpack-hot-middleware": "^2.10.0" + }, + "scripts": { + "start": "node server.js" + } +} diff --git a/server.js b/server.js new file mode 100644 index 0000000..6d2cc31 --- /dev/null +++ b/server.js @@ -0,0 +1,58 @@ +'use strict'; + + +require("coffee-script/register"); +require('core-js/fn/object/assign'); + + +var express = require('express'); +var url = require('url'); +var webpack = require('webpack'); + +var webpackDevMiddleware = require('webpack-dev-middleware'); +var webpackHotMiddleware = require('webpack-hot-middleware'); + +var bodyParser = require('body-parser'); + +var config = require('./webpack.config'); + +var host = '127.0.0.1'; +var port = 8080; + +var server = express(); +var compiler = webpack(config); + + + +server.use(webpackDevMiddleware(compiler, { + publicPath: config.output.publicPath, + hot: true, + historyApiFallback: true, + stats: { + colors: true, + hash: false, + version: false, + chunks: false, + children: false, + }, + headers: { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Headers': 'X-Requested-With' + }, +})); + +server.use(webpackHotMiddleware(compiler)); + + +server.use(bodyParser.json()); +server.use(bodyParser.urlencoded({ extended: true })); + +server.get('/', function(req, res) { + res.sendFile(config.resolve.root + '/index.dev.html'); +}); + + +server.listen(port, 'localhost', err => { + if (err) console.log(`=> OMG!!! 🙀 ${err}`); + console.log(`=> 🔥 Webpack dev server is running on port ${port}`); +}); diff --git a/src/main/cjsx/components/App.cjsx b/src/main/cjsx/components/App.cjsx new file mode 100644 index 0000000..e232d9e --- /dev/null +++ b/src/main/cjsx/components/App.cjsx @@ -0,0 +1,25 @@ +React=require 'react' +mui=require('material-ui') +rawTheme=require('source/cjsx/components/Theme') +AppBar=mui.AppBar + +RaisedButton=mui.RaisedButton + + +class App extends React.Component + constructor: (props, context)-> + super(props, context) + + @childContextTypes : + muiTheme: React.PropTypes.object + + getChildContext: -> + muiTheme: mui.Styles.getMuiTheme(rawTheme) + + render: -> +
+ + +
+ +module.exports=App diff --git a/src/main/cjsx/components/Theme.cjsx b/src/main/cjsx/components/Theme.cjsx new file mode 100644 index 0000000..75a705c --- /dev/null +++ b/src/main/cjsx/components/Theme.cjsx @@ -0,0 +1,23 @@ +mui=require('material-ui') +Colors=require('material-ui/lib/styles/colors') +ColorManipulator=mui.Utils.ColorManipulator +Spacing=require('material-ui/lib/styles/spacing') +zIndex=require('material-ui/lib/styles/zIndex') + +module.exports= + spacing: Spacing + zIndex: zIndex + fontFamily: 'Roboto, sans-serif' + palette: + primary1Color: Colors.red500 + primary2Color: Colors.cyan700 + primary3Color: Colors.lightBlack + accent1Color: Colors.pinkA200 + accent2Color: Colors.grey100 + accent3Color: Colors.grey500 + textColor: Colors.darkBlack + alternateTextColor: Colors.white + canvasColor: Colors.white + borderColor: Colors.grey300 + disabledColor: ColorManipulator.fade(Colors.darkBlack, 0.3) + pickerHeaderColor: Colors.cyan500 \ No newline at end of file diff --git a/src/main/cjsx/main.cjsx b/src/main/cjsx/main.cjsx new file mode 100644 index 0000000..4ebd477 --- /dev/null +++ b/src/main/cjsx/main.cjsx @@ -0,0 +1,12 @@ +require('core-js/fn/object/assign') +React=require('react') +ReactDom=require('react-dom') +App = require('source/cjsx/components/App') + +window.React = React +window.ReactDom = ReactDom + +document.addEventListener("DOMContentLoaded", + (event)-> + ReactDom.render(, document.getElementById 'app') +) \ No newline at end of file diff --git a/src/main/scss/main.scss b/src/main/scss/main.scss new file mode 100644 index 0000000..e69de29 diff --git a/webpack.config.coffee b/webpack.config.coffee new file mode 100644 index 0000000..36ba116 --- /dev/null +++ b/webpack.config.coffee @@ -0,0 +1,135 @@ +'use strict' +path = require('path') +webpack = require('webpack') +autoprefixer = require('autoprefixer') + +module.exports = + debug: true + resolve: + root: __dirname + modulesDirectories: [ 'node_modules' ] + extensions: [ + '' + '.cjsx' + '.coffee' + '.jsx' + '.js' + ] + alias: + underscore: 'lodash' + source: path.join(__dirname, '/src/main') + entry: + main: [ + 'webpack-hot-middleware/client' + 'source/cjsx/main' + ], + vendor: [ + 'normalize.css/normalize.css' + 'es5-shim' + 'es5-shim/es5-sham' + 'es6-shim' + 'es6-shim/es6-sham' + 'json3' + 'html5shiv' + 'html5shiv/dist/html5shiv-printshiv' + ] + output: + path: path.join(__dirname, './assets') + filename: '[name].js' + publicPath: '/assets/' + pathinfo: true + devtool: 'eval' + plugins: [ + new (webpack.PrefetchPlugin)("react") + new (webpack.PrefetchPlugin)("react/lib/ReactComponentBrowserEnvironment") + new (webpack.HotModuleReplacementPlugin) + new (webpack.NoErrorsPlugin) + new (webpack.ProvidePlugin)( + 'window.Tether': 'tether' + ) +# new (webpack.optimize.CommonsChunkPlugin)( +# name: 'vendor', +# chunks: ['vensor'], +# filename: 'vendor.js', +# minChunks: Infinity +# ) + ] + module: + preLoaders: [ + test: /\.(js|jsx)$/ + loader: 'eslint' + exclude: /node_modules/ + ] + loaders: [ + test: /\.(js|jsx)?$/ + exclude: /(node_modules|bower_components)/ + loader: [ + 'react-hot' + 'babel' + ]#'babel-loader' is also a legal name to reference + query: + presets: ['es2015'] + plugins: ['transform-runtime'] + , + test: /\.cjsx$/ + loaders: [ + 'react-hot' + 'coffee' + 'cjsx' + ]#'babel-loader' is also a legal name to reference + , + test: /\.coffee$/ + loaders: [ + 'react-hot' + 'coffee' + ]#'babel-loader' is also a legal name to reference + , + test: /\.scss$/ + loaders: [ + 'style' + 'css' + 'postcss' + 'sass' + ] + , + test: /\.css$/ + exclude: /.*\.min.css/ + loaders: [ + 'style' + 'css' + 'postcss' + ] + , + test: /\.png$/ + loader: 'url?limit=8192&mimetype=image/png' + , + test: /\.jpe?g$/ + loader: 'url?limit=8192&mimetype=image/jpg' + , + test: /\.gif$/ + loader: 'url?limit=8192&mimetype=image/gif' + , + test: /\.svg(\?v=\d+\.\d+\.\d+)?$/ + loader: 'url?limit=8192&mimetype=image/svg+xml' + , + test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/ + loader: 'url?limit=8192&mimetype=application/font-woff2' + , + test: /\.woff(\?v=\d+\.\d+\.\d+)?$/ + loader: 'url?limit=8192&mimetype=application/font-woff' + , + test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/ + loader: 'url?limit=8192&mimetype=application/octet-stream' + , + test: /\.eot(\?v=\d+\.\d+\.\d+)?$/ + loader: 'file' + ] + postcss: [ autoprefixer ] + eslint: + emitErrors: true + reporter: (results) -> + results.map((result) -> + result.messages.map((msg) -> + ' ' + msg.message + '(' + msg.ruleId + ')' + ' @ line ' + msg.line + ' column ' + msg.column + ' - ' + (if msg.fatal then 'fatal, ' else '') + 'severity: ' + msg.severity + ).join '\n' + ).join '\n' diff --git a/webpack.prod.config.coffee b/webpack.prod.config.coffee new file mode 100644 index 0000000..695e842 --- /dev/null +++ b/webpack.prod.config.coffee @@ -0,0 +1,131 @@ +'use strict' +path = require('path') +webpack = require('webpack') +autoprefixer = require('autoprefixer') +extractTextPlugin = require('extract-text-webpack-plugin') + +module.exports = + debug: false + resolve: + root: __dirname + modulesDirectories: ['node_modules'] + extensions: [ + '' + '.cjsx' + '.coffee' + '.jsx' + '.js' + ] + alias: + underscore: 'lodash' + source: path.join(__dirname, '/src/main') + entry: + main: [ + 'source/cjsx/main' + ] + vendor: [ + 'normalize.css/normalize.css' + 'es5-shim' + 'es5-shim/es5-sham' + 'es6-shim' + 'es6-shim/es6-sham' + 'json3' + 'html5shiv' + 'html5shiv/dist/html5shiv-printshiv' + ] + output: + path: path.join(__dirname, './assets') + filename: '[name].js' +# filename: "[name]-[chunkhash].js" +# chunkFilename: "[name]-[chunkhash].js" + publicPath: '/assets/' + pathinfo: false + plugins: [ + new (webpack.PrefetchPlugin)("react") + new (webpack.PrefetchPlugin)("react/lib/ReactComponentBrowserEnvironment") + new (extractTextPlugin)('[name].css', { allChunks: true }) + new (webpack.NoErrorsPlugin) + new (webpack.optimize.DedupePlugin), + new (webpack.optimize.OccurrenceOrderPlugin)(true) + new (webpack.optimize.UglifyJsPlugin)( + sourceMap: true + mangle: + except: [ + '$super' + '$' + '_' + 'exports' + 'require' + ] + minimize: true + output: + comments: false + compress: + warnings: false + ) + ] + module: + preLoaders: [ + test: /\.(js|jsx)$/ + loader: 'eslint' + exclude: /node_modules/ + ] + loaders: [ + test: /\.(js|jsx)?$/ + exclude: /(node_modules|bower_components)/ + loader: [ + 'babel' + ]#'babel-loader' is also a legal name to reference + query: + presets: ['es2015'] + plugins: ['transform-runtime'] + , + test: /\.cjsx$/ + loaders: [ + 'coffee' + 'cjsx' + ]#'babel-loader' is also a legal name to reference + , + test: /\.coffee$/ + loader: 'coffee' + , + test: /\.scss$/ + loader: extractTextPlugin.extract('style', 'css?minimize!postcss!sass') + , + test: /\.css$/ + exclude: /.*\.min.css/ + loader: extractTextPlugin.extract('style', 'css?minimize!postcss') + , + test: /\.png$/ + loader: 'url?limit=8192&mimetype=image/png' + , + test: /\.jpe?g$/ + loader: 'url?limit=8192&mimetype=image/jpg' + , + test: /\.gif$/ + loader: 'url?limit=8192&mimetype=image/gif' + , + test: /\.svg(\?v=\d+\.\d+\.\d+)?$/ + loader: 'url?limit=8192&mimetype=image/svg+xml' + , + test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/ + loader: 'url?limit=8192&mimetype=application/font-woff2' + , + test: /\.woff(\?v=\d+\.\d+\.\d+)?$/ + loader: 'url?limit=8192&mimetype=application/font-woff' + , + test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/ + loader: 'url?limit=8192&mimetype=application/octet-stream' + , + test: /\.eot(\?v=\d+\.\d+\.\d+)?$/ + loader: 'file' + ] + postcss: [ autoprefixer ] + eslint: + emitErrors: true + reporter: (results) -> + results.map((result) -> + result.messages.map((msg) -> + ' ' + msg.message + '(' + msg.ruleId + ')' + ' @ line ' + msg.line + ' column ' + msg.column + ' - ' + (if msg.fatal then 'fatal, ' else '') + 'severity: ' + msg.severity + ).join '\n' + ).join '\n'