-
-
Save cinic/8b5f3a11aa0a2b19e812c553e6ce87d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '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