Skip to content

Commit

Permalink
chore: prepare production config
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrkalinin committed Sep 21, 2016
1 parent 4a5b1a0 commit d757e95
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
===============
/dist
/.tmp
/_build

#OS generated files #
=====================
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"bootstrap": "^3.3.6",
"bootstrap-switch": "~3.0.2",
"bootstrap-tagsinput": "^0.7.1",
"connect": "^3.5.0",
"d3": "~3.5.15",
"data-wrangler": "^1.0.5",
"datalib": "^1.7.2",
Expand All @@ -40,6 +41,7 @@
"jstat": "~1.5.2",
"ngHandsontable": "git+https://github.com/handsontable/ngHandsontable.git",
"select2": "^4.0.3",
"serve-static": "^1.11.1",
"typeahead.js": "git+https://github.com/twitter/typeahead.js.git"
},
"devDependencies": {
Expand Down Expand Up @@ -67,6 +69,7 @@
"less-loader": "*",
"phantomjs2": "~2.2.0",
"raw-loader": "*",
"strip-loader": "^0.1.2",
"style-loader": "*",
"url-loader": "^0.5.7",
"webpack": "1.13.0",
Expand All @@ -78,7 +81,8 @@
"scripts": {
"build": "node_modules/webpack/bin/webpack.js",
"watch": "node_modules/webpack/bin/webpack.js --watch",
"serve": "node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot -d --colors --content-base _build/"
"serve": "node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot -d --colors --content-base _build/",
"prod": "node_modules/webpack/bin/webpack.js -p --config ./webpack.production.config.coffee"
},
"license": "LGPL-3.0"
}
5 changes: 5 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var connect = require('connect');
var serveStatic = require('serve-static');
connect().use(serveStatic(__dirname)).listen(3000, function(){
console.log('Server running on 300...');
});
109 changes: 109 additions & 0 deletions webpack.production.config.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
webpack = require 'webpack'
production = process.env.NODE_ENV is 'production'

appRoot = "#{__dirname}/app"

module.exports =
cache: true
debug: !production
devtool: production ? false : 'eval'

# The entry point
entry: [
"#{appRoot}/app.coffee"
]

output:
path: './_build'
filename: 'socrat.js'
chunkFilename: "[id].socrat.js"

devServer: {
hot: true,
}

module:
loaders: [
test: /\.jsx?$/
exclude: /(node_modules|bower_components)/
loader: 'babel'
,
test: /\.less$/
loader: 'style!css!less'
,
test: /\.css$/
loader: 'style!css'
,
test: /\.coffee$/
loader: 'coffee'
,
test: /\.jade$/
loader: 'jade-loader'
,
test: /\.html$/,
loader: 'html'
,
# required for bootstrap icons
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/
loader: "file"
,
test: /\.(woff|woff2)$/
loader: 'url?prefix=font/&limit=5000&mimetype=application/font-woff'
,
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/
loader: "url?limit=10000&mimetype=application/octet-stream"
,
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/
loader: "url?limit=10000&mimetype=image/svg+xml"
,
test: /\.jpe?g$|\.gif$|\.png$/i
loader: "url"
,
test: /[\/]datavore-d0\.1\.js$/
loader: 'exports?dv'
,
test: /[\/]highlight\.js$/
loader: 'exports?Highlight'
,
test: /[\/]dw\.js$/
loader: 'imports?dv=datavore!imports?Highlight=highlight!exports?dw'
,
test: /[\/]flat-ui\.js$/
loader: 'imports?this=>window'
]

resolve:

extensions: [
''
'.js'
'.coffee'
'.less'
'.css'
]

root: appRoot

alias:
datavore: 'data-wrangler/lib/datavore/datavore-d0.1.js'
highlight: 'data-wrangler/lib/Highlight/highlight.js'
'jquery-ui': 'jquery-ui/ui/widgets'

plugins: [

# disable dynamic requires
new webpack.ContextReplacementPlugin /.*$/, /a^/

new webpack.ProvidePlugin
$: "jquery",
jQuery: "jquery",
'window.jQuery': "jquery"

new webpack.ProvidePlugin
d3: "d3"

new webpack.optimize.CommonsChunkPlugin('common.js')
new webpack.optimize.DedupePlugin()
new webpack.optimize.UglifyJsPlugin()
new webpack.optimize.AggressiveMergingPlugin()
]

0 comments on commit d757e95

Please sign in to comment.