diff --git a/package.json b/package.json index 8b4f8327..a25225a5 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "scripts": { "start": "BABEL_DISABLE_CACHE=1 NODE_ENV=development nodemon index.js", "lint": "eslint client server", + "build": "NODE_ENV=production webpack --config webpack.config.prod.js", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "Cassie Tarakajian", @@ -31,6 +32,7 @@ "eslint-plugin-import": "^1.9.2", "eslint-plugin-jsx-a11y": "^1.5.3", "eslint-plugin-react": "^5.2.2", + "extract-text-webpack-plugin": "^1.0.1", "file-loader": "^0.8.5", "node-sass": "^3.7.0", "nodemon": "^1.9.2", diff --git a/server/server.js b/server/server.js index db9ed773..02fc37c4 100644 --- a/server/server.js +++ b/server/server.js @@ -9,7 +9,7 @@ import path from 'path'; // Webpack Requirements import webpack from 'webpack'; -import config from '../webpack.config'; +import config from '../webpack.config.dev'; import webpackDevMiddleware from 'webpack-dev-middleware'; import webpackHotMiddleware from 'webpack-hot-middleware'; diff --git a/webpack.config.js b/webpack.config.dev.js similarity index 100% rename from webpack.config.js rename to webpack.config.dev.js diff --git a/webpack.config.prod.js b/webpack.config.prod.js new file mode 100644 index 00000000..586bdd26 --- /dev/null +++ b/webpack.config.prod.js @@ -0,0 +1,56 @@ +var webpack = require('webpack'); +var ExtractTextPlugin = require('extract-text-webpack-plugin'); + +module.exports = { + entry: { + app: [ + './client/index.js' + ], + vendor: [ + 'react', + 'react-dom' + ] + }, + + output: { + path: __dirname + '/dist', + filename: 'bundle.js', + publicPath: '/dist/' + }, + + resolve: { + extensions: ['', '.js', '.jsx'], + }, + + module: { + loaders: [ + { + test: /\.scss$/, + exclude: /node_modules/, + loader: ExtractTextPlugin.extract('style', 'css?importLoaders=2&sourceMap!sass?outputStyle=expanded&sourceMap=true&sourceMapContents=true!postcss-loader') + }, + { + test: /\.jsx?$/, + exclude: /node_modules/, + loader: 'babel' + }, + { + test: /\.svg$/, + loader: 'file' + } + ] + }, + + plugins: [ + new webpack.DefinePlugin({ + 'process.env': { + 'NODE_ENV': JSON.stringify('production') + } + }), + new webpack.optimize.UglifyJsPlugin({ + compressor: { + warnings: false + } + }) + ] +}; \ No newline at end of file