Created
June 3, 2017 07:18
-
-
Save renshenhe/bce905b080d8d61ecc72b173813fa7db 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
/* @flow */ | |
import path from 'path'; | |
import webpack from 'webpack'; | |
import ExtractTextPlugin from 'extract-text-webpack-plugin'; | |
import { isProd, WDS_PORT, WEB_PORT } from './src/shared/config'; | |
const extractSass = new ExtractTextPlugin({ | |
filename: '[name].[contenthash].css', | |
disable: process.env.NODE_ENV !== 'production', | |
}); | |
export default { | |
entry: [ | |
'react-hot-loader/patch', | |
'./src/client', | |
], | |
output: { | |
filename: 'js/bundle.js', | |
path: path.resolve(__dirname, 'dist'), | |
publicPath: isProd ? '/static/' : `http://localhost:${WDS_PORT}/dist/`, | |
}, | |
module: { | |
rules: [ | |
{ test: /\.(js|jsx)$/, use: 'babel-loader', exclude: /node_modules/ }, | |
{ test: /\.scss$/, | |
use: [ | |
{ loader: 'style-loader' }, | |
{ loader: 'css-loader', }, | |
{ loader: 'sass-loader', } | |
], | |
} | |
], | |
}, | |
devtool: isProd ? false : 'source-map', | |
resolve: { | |
extensions: ['.js', '.jsx'], | |
}, | |
devServer: { | |
port: WDS_PORT, | |
hot: true, | |
headers: { 'Access-Control-Allow-Origin': `http://localhost:${WEB_PORT}` }, | |
}, | |
plugins: [ | |
new webpack.optimize.OccurrenceOrderPlugin(), | |
new webpack.HotModuleReplacementPlugin(), | |
new webpack.NamedModulesPlugin(), | |
new webpack.NoEmitOnErrorsPlugin(), | |
extractSass, | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment