ducky/web
2015-07-07
Parent:5d47855181e1
ducky/web/webpack.config.js
Implement subscriptions. Create a Subscription model and a Subscriptions collection, and attach them to the app context. Add a helper to our Profile model to retrieve the Subscription of that model. Still not sure this should be on the Profile--wouldn't it be better on the Me model? Isn't that generally where we would need it?
1 require('babel/register')
2 var webpack = require('webpack')
3 var ExtractTextPlugin = require('extract-text-webpack-plugin')
4 var path = require('path')
5 var neat = require('node-neat').includePaths
6 var env = process.env.NODE_ENV || 'development'
8 module.exports = function () {
9 var isDev = env !== 'production'
10 var cssLoader = isDev ? 'css-loader?sourceMap' : 'css-loader?sourceMap'
11 var sassLoader = isDev ? 'sass-loader?sourceMap' : 'sass-loader?sourceMap'
12 var bourbonPaths = neat.map(function(p) {
13 return "includePaths[]=" + p
14 }).join("&")
15 if (sassLoader.indexOf('?') === -1) {
16 sassLoader += '?'
17 } else {
18 sassLoader += '&'
19 }
20 sassLoader += bourbonPaths
21 var manifest = {
22 entry: path.join(__dirname, 'src', 'main.js'),
23 output: {
24 path: path.join(__dirname, 'build', 'static'),
25 publicPath: '/static/',
26 filename: 'bundle.js'
27 },
28 module: {
29 loaders: [
30 { test: /(\.js$)|(\.jsx$)/, loader: 'babel-loader', exclude: /node_modules/ },
31 { test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', cssLoader) },
32 { test: /\.scss$/, loader: ExtractTextPlugin.extract('style-loader', cssLoader + '!' + sassLoader) },
33 { test: /\.(svg|png|jpg|jpeg)$/, loader: 'url-loader?limit=8192'}
34 ]
35 },
36 resolve: {
37 extensions: ['', '.js', '.jsx', '.scss']
38 },
39 plugins: [new ExtractTextPlugin("main.css")],
40 modulesDirectoires: ["node_modules"],
41 devtool: 'source-map',
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 }),
80 new webpack.DefinePlugin({
81 'process.env': {NODE_ENV: JSON.stringify('production')}
82 })
83 )
84 }
85 return manifest
86 }()