diff --git a/.gitignore b/.gitignore index babc0542..e78e7b61 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ =============== /dist /.tmp +/_build #OS generated files # ===================== diff --git a/package.json b/package.json index 9874931f..d424b2d6 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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": { @@ -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", @@ -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" } diff --git a/server.js b/server.js new file mode 100644 index 00000000..6c7aac0c --- /dev/null +++ b/server.js @@ -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...'); +}); diff --git a/webpack.production.config.coffee b/webpack.production.config.coffee new file mode 100644 index 00000000..21da751c --- /dev/null +++ b/webpack.production.config.coffee @@ -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() + ]