Skip to content

Instantly share code, notes, and snippets.

@AndrewRayCode
Created June 28, 2016 05:24
Show Gist options
  • Save AndrewRayCode/0cf9f5aec1961335644fadb0a9298218 to your computer and use it in GitHub Desktop.
Save AndrewRayCode/0cf9f5aec1961335644fadb0a9298218 to your computer and use it in GitHub Desktop.
// Webpack config for development
var fs = require('fs');
var path = require('path');
var webpack = require('webpack');
var assetsPath = path.resolve(__dirname, '../static/dist');
var host = (process.env.HOST || 'localhost');
var port = parseInt(process.env.PORT) + 1 || 3001;
// https://github.com/halt-hammerzeit/webpack-isomorphic-tools
var WebpackIsomorphicToolsPlugin = require('webpack-isomorphic-tools/plugin');
var webpackIsomorphicToolsPlugin = new WebpackIsomorphicToolsPlugin(require('./webpack-isomorphic-tools'));
var WebpackNotifierPlugin = require('webpack-notifier');
module.exports = {
devtool: 'inline-source-map',
context: path.resolve(__dirname, '..'),
entry: {
app_assets: [ './src/client.js' ],
vendor: [
'react',
'react-dom',
'three',
'querystring',
'strip-ansi',
'ansi-regex',
'ansi-html',
'html-entities',
'babel-runtime/core-js',
'babel-polyfill',
'process',
'fbjs',
'redux',
'redux-async-connect',
'react-router',
'warning',
'react-three-renderer',
'react-helmet',
'react-proxy',
'dom-helpers',
'scroll-behavior',
'react-router',
'history',
'strict-uri-encode'
],
assets: [ './src/assets.js' ],
},
output: {
path: assetsPath,
filename: '[name].dll.js',
library: '[name]', // added?
publicPath: 'http://' + host + ':' + ( port - 1 ) + '/dist/'
},
module: {
loaders: [
{ test: /\.typeface\.js$/, loader: "file" },
{ test: /\.jsx?$/, exclude: /node_modules|\.typeface\.js$/, loaders: ['babel']},
{ test: /models.+\.json$/, loader: "file" },
{ test: /\.json$/, exclude: /models.+\.json$/, loader: "json-loader" },
{ test: /\.less$/, loader: "style!css?modules&importLoaders=2&sourceMap&localIdentName=[local]___[hash:base64:5]!autoprefixer?browsers=last 2 version!less?outputStyle=expanded&sourceMap" },
{ test: /\.scss$/, exclude: /global\.scss$/, loader: "style!css?modules&importLoaders=2&sourceMap&localIdentName=[local]___[hash:base64:5]!autoprefixer?browsers=last 2 version!sass?outputStyle=expanded&sourceMap" },
// Note the global laoder does not have localIdentName nor modules enabled
// for the css loader, so any classes in there won't get mangled
{ test: /global\.scss$/, loader: "style!css?importLoaders=2&sourceMap!autoprefixer?browsers=last 2 version!sass?outputStyle=expanded&sourceMap" },
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" },
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" },
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream" },
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" },
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml" },
{ test: /\.(obj|dae)$/, loader: "file" },
{ test: webpackIsomorphicToolsPlugin.regular_expression('images'), loader: 'url-loader?limit=10240' }
]
},
progress: true,
resolve: {
modulesDirectories: [
'src',
'assets',
'node_modules'
],
extensions: [ '', '.json', '.js', '.jsx' ]
},
plugins: [
new webpack.DllPlugin({
name: '[name]',
path: path.join( assetsPath, '[name]-manifest.json' ),
}),
new webpack.IgnorePlugin( /webpack-stats\.json$/ ),
new webpack.DefinePlugin({
// This speeds up some local libraries for me, you may not want it
'process.env': {
NODE_ENV: '"production"'
},
__CLIENT__: true,
__SERVER__: false,
__DEVELOPMENT__: true,
__DEVTOOLS__: false // <-------- DISABLE redux-devtools HERE
}),
webpackIsomorphicToolsPlugin.development(),
new WebpackNotifierPlugin(),
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment