ducky/web

Paddy 2015-05-31 Parent:b9d0efb44eaa Child:5d47855181e1

6:a641906b8267 Go to Latest

ducky/web/webpack.config.js

Enable catch-all in our ValidationError component. We're doing this an ugly, hacky way. But it works, and right now, that's what counts. To match our params/fields/headers properties on the ValidationError component, we're going to add the notParams/notFields/notHeaders properties--they match any error _not_ targeting those params/fields/headers. Basically, "any error that wouldn't be caught by these filters". Which is an ugly, but workable, solution for a catch-all ValidationError--just tell it to catch anything but the params/fields/headers that are being handled by the other ValidationErrors. Our implementation of this in the RegisterPage component validates (ha!) that it's at least workable model, if not overly pretty. Also, I anticipate some human error bugs in the future, where one of the field-specific ValidationErrors gets updated and the catch-all ValidationError does not. But whatever. For now, this is Good Enoughâ„¢.

History
1 require('babel/register')
2 var webpack = require('webpack')
3 var commonsPlugin = new webpack.optimize.CommonsChunkPlugin('common.js')
4 var ExtractTextPlugin = require('extract-text-webpack-plugin')
5 var path = require('path')
6 var neat = require('node-neat').includePaths
7 var env = process.env.NODE_ENV || 'development'
9 module.exports = function () {
10 var isDev = env !== 'production'
11 var cssLoader = isDev ? 'css-loader?sourceMap' : 'css-loader'
12 var sassLoader = isDev ? 'sass-loader?sourceMap' : 'sass-loader'
13 var bourbonPaths = neat.map(function(p) {
14 return "includePaths[]=" + p
15 }).join("&")
16 if (sassLoader.indexOf('?') === -1) {
17 sassLoader += '?'
18 } else {
19 sassLoader += '&'
20 }
21 sassLoader += bourbonPaths
22 var manifest = {
23 entry: path.join(__dirname, 'src', 'main.js'),
24 output: {
25 path: path.join(__dirname, 'build', 'static'),
26 publicPath: '/static/',
27 filename: 'bundle.js'
28 },
29 module: {
30 loaders: [
31 { test: /(\.js$)|(\.jsx$)/, loader: 'babel-loader', exclude: /node_modules/ },
32 { test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', cssLoader) },
33 { test: /\.scss$/, loader: ExtractTextPlugin.extract('style-loader', cssLoader + '!' + sassLoader) },
34 { test: /\.(svg|png|jpg|jpeg)$/, loader: 'url-loader?limit=8192'}
35 ]
36 },
37 resolve: {
38 extensions: ['', '.js', '.jsx', '.scss']
39 },
40 plugins: [commonsPlugin, new ExtractTextPlugin("main.css")],
41 modulesDirectoires: ["node_modules"],
42 }
43 if (isDev) {
44 manifest.host = '0.0.0.0'
45 manifest.port = '3000'
46 manifest.devtool = 'source-map'
48 if (typeof manifest.entry === 'string') {
49 manifest.entry = [manifest.entry]
50 }
52 manifest.entry.unshift(
53 'webpack-dev-server/client?http://' + manifest.host + ':' + manifest.port,
54 'webpack/hot/dev-server'
55 )
57 manifest.plugins = manifest.plugins.concat([
58 new webpack.HotModuleReplacementPlugin(),
59 new webpack.NoErrorsPlugin()
60 ])
62 if (manifest.module.loaders[0].loader && !manifest.module.loaders[0].loaders) {
63 manifest.module.loaders[0].loaders = [manifest.module.loaders[0].loader]
64 delete manifest.module.loaders[0].loader
65 }
67 manifest.module.loaders[0].loaders.unshift('react-hot')
68 } else {
69 manifest.plugins.push(
70 new webpack.optimize.DedupePlugin(),
71 new webpack.optimize.OccurenceOrderPlugin(true),
72 new webpack.optimize.UglifyJsPlugin({
73 compress: {
74 warnings: false
75 },
76 output: {
77 comments: false
78 },
79 sourceMap: false
80 }),
81 new webpack.DefinePlugin({
82 'process.env': {NODE_ENV: JSON.stringify('production')}
83 })
84 )
85 }
86 return manifest
87 }()