Commit c065df3f authored by Ray Schamp's avatar Ray Schamp

Use webpack for static assets

parent 133e42de
......@@ -8,7 +8,6 @@ WEBPACK=./node_modules/.bin/webpack
build:
@make clean
@make static
@make translations
@make webpack
......@@ -30,9 +29,6 @@ else
eb deploy -l $$(git rev-parse --verify --short=5 HEAD) -m "$$(git log -1 --pretty=%s)"
endif
static:
cp -a ./static/. ./build/
translations:
./src/scripts/build-locales locales/translations.json
......
......@@ -13,12 +13,14 @@ var log = require('./log');
var proxies = require('./proxies.json');
var routes = require('./routes.json');
var isProduction = process.env.NODE_ENV === 'production';
// Create server
var app = express();
app.disable('x-powered-by');
// Block POST & PUT requests in production
if (process.env.NODE_ENV === 'production') {
if (isProduction) {
app.use(function (req, res, next) {
if (req.method === 'GET') return next();
if (req.method === 'OPTIONS') return next();
......@@ -65,8 +67,8 @@ if (typeof process.env.NODE_SENTRY_DSN === 'string') {
});
}
// Bind proxies in development
if (process.env.NODE_ENV !== 'production') {
if (!isProduction) {
// Bind proxies in development
var proxyHost = process.env.PROXY_HOST || 'https://scratch.mit.edu';
app.use('/', proxy(proxyHost, {
......
var CopyWebpackPlugin = require('copy-webpack-plugin');
var path = require('path');
var webpack = require('webpack');
......@@ -9,9 +10,7 @@ var entry = {
main: './src/main.jsx'
};
routes.forEach(function (route) {
if ( ! route.static ) {
entry[route.view] = './src/views/' + route.view + '/' + route.view + '.jsx';
}
entry[route.view] = './src/views/' + route.view + '/' + route.view + '.jsx';
});
// Config
......@@ -25,8 +24,8 @@ module.exports = {
'react-intl': 'ReactIntl'
},
output: {
path: path.resolve(__dirname, 'build/js'),
filename: '[name].bundle.js'
path: path.resolve(__dirname, 'build'),
filename: 'js/[name].bundle.js'
},
module: {
loaders: [
......@@ -53,6 +52,9 @@ module.exports = {
fs: 'empty'
},
plugins: [
new CopyWebpackPlugin([
{from: 'static'}
]),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment