test_web/webpack.config.js
2017-05-25 17:44:58 +09:00

93 lines
2.7 KiB
JavaScript

const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: {
ts: [
'./src/ts/index.tsx'
],
vendor: [
'react',
'react-dom',
'react-router',
'react-router-dom'
]
},
output: {
filename: 'bundle.js',
path: __dirname + '/dist',
},
devtool: 'source-map',
devServer: {
hot: true, // enable HMR on the server
inline: true,
historyApiFallback: true,
contentBase: [__dirname + '/public', __dirname + '/dist', __dirname + '/node_modules'], // match the output path
publicPath: '/' ,// match the output `publicPath`
host: '192.168.1.209',
port: 9091,
stats: {
colors: true
},
},
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: ['.ts', '.tsx', '.js', '.json']
},
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader'
},
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'postcss-loader', 'sass-loader']
})
},
{
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
// loader: 'url?limit=10000'
loaders: [
'file-loader?hash=sha512&digest=hex&name=[hash].[ext]',
'image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false'
]
},
{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader'
}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity,
filename: 'vendor.bundle.js'
}),
new ExtractTextPlugin({
filename: __dirname + '/dist/css/[name].bundle.css',
disable: false,
allChunks: true
}),
new webpack.HotModuleReplacementPlugin(), // enable HMR globally
],
// When importing a module whose path matches one of the following, just
// assume a corresponding global variable exists and use that instead.
// This is important because it allows us to avoid bundling all of our
// dependencies, which allows browsers to cache those libraries between builds.
// externals: {
// 'react': 'React',
// 'react-dom': 'ReactDOM'
// },
};