Skip to content

Instantly share code, notes, and snippets.

@drager
Created March 3, 2016 07:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save drager/5f190a170bd55d415150 to your computer and use it in GitHub Desktop.
Save drager/5f190a170bd55d415150 to your computer and use it in GitHub Desktop.
'use strict';
const path = require('path');
const webpack = require('webpack');
const production = process.env.NODE_ENV === 'production';
const babelPlugins = ['jsx-tagclass'];
const babelProdPlugins = babelPlugins.concat(
['transform-react-constant-elements', 'transform-react-inline-elements']
);
const config = {
entry: {
javascript: ['babel-polyfill', './app/index'],
html: './app/index.html'
},
output: {
path: './dist',
filename: 'app.js',
},
debug: !production,
devtool: production ? 'source-map' : 'eval-source-map',
module: {
loaders: [
{
test: /\.ts(x?)$/,
exclude: /node_modules\/(?!common)/,
loaders: [
'react-hot',
'babel?' + JSON.stringify({
presets: [
require.resolve('babel-preset-react'),
require.resolve('babel-preset-es2015'),
require.resolve('babel-preset-stage-2'),
],
plugins: production
? babelProdPlugins
: babelPlugins,
}),
'ts',
],
},
{
test: /\.html$/,
loader: 'file?name=[name].[ext]',
},
{
test: /\.css$/,
loader: 'style!css',
},
{
test: /\.scss$/,
exclude: /\.global\.scss$/,
loaders: [
'style',
'css?modules',
'resolve-url',
'sass',
],
},
{
test: /\.global\.scss$/,
loaders: [
'style',
'css',
'resolve-url',
'sass',
],
},
]
},
resolve: {
extensions: ['', '.js', '.ts', '.tsx'],
modulesDirectories: ['node_modules', path.resolve('./node_modules')],
},
};
if (production) {
config.plugins = [
new webpack.optimize.UglifyJsPlugin({
comments: false,
test: /\.js$/,
}),
];
}
module.exports = config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment