ducky/web
ducky/web/webpack.config.js
Update to use plans instead of PWYW. If we're going to lean on Stripe for most of our subscription processing, we need to use plans, instead of pay what you want. This updates the page to replace our amount input with a plan select box. It also removes the nonsense about finding your first charge date, because Stripe forced us into a simpler, but harder to predict, billing model. We also updated our CSS to work with select boxes, as well as text inputs.
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 }()