2018-03-31 05:07:44 +00:00
|
|
|
const path = require('path');
|
|
|
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
|
|
|
|
const env = process.env.NODE_ENV;
|
|
|
|
|
|
|
|
module.exports = {
|
2018-04-06 02:41:19 +00:00
|
|
|
entry: './src/transport.ts',
|
2018-03-31 05:07:44 +00:00
|
|
|
output: {
|
|
|
|
filename: 'transport.js',
|
|
|
|
path: path.resolve(__dirname, 'dist'),
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
2018-04-06 02:41:19 +00:00
|
|
|
presets: [
|
|
|
|
'@babel/preset-env',
|
|
|
|
],
|
|
|
|
plugins: [
|
|
|
|
'@babel/proposal-class-properties',
|
|
|
|
'@babel/proposal-object-rest-spread',
|
|
|
|
],
|
|
|
|
cacheDirectory: env === 'development',
|
2018-03-31 05:07:44 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-04-06 02:41:19 +00:00
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
use: 'ts-loader',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
},
|
2018-03-31 05:07:44 +00:00
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: env === 'production'
|
|
|
|
? ExtractTextPlugin.extract({
|
|
|
|
fallback: 'style-loader',
|
|
|
|
use: ['css-loader'],
|
|
|
|
})
|
|
|
|
: ['style-loader', 'css-loader'],
|
|
|
|
},
|
2018-04-15 08:02:54 +00:00
|
|
|
{
|
|
|
|
test: /\.png$/,
|
|
|
|
use: 'file-loader',
|
|
|
|
},
|
2018-03-31 05:07:44 +00:00
|
|
|
],
|
|
|
|
},
|
2018-04-06 02:41:19 +00:00
|
|
|
resolve: {
|
|
|
|
extensions: ['.tsx', '.ts', '.js'],
|
|
|
|
},
|
2018-03-31 05:07:44 +00:00
|
|
|
plugins: [
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: path.join(__dirname, 'index.html'),
|
|
|
|
}),
|
|
|
|
new ExtractTextPlugin({
|
|
|
|
disable: env === 'development',
|
|
|
|
filename: '[name].css',
|
|
|
|
}),
|
|
|
|
],
|
2018-03-31 05:50:39 +00:00
|
|
|
devtool: 'cheap-module-eval-source-map',
|
2018-03-31 05:07:44 +00:00
|
|
|
devServer: {
|
|
|
|
contentBase: path.join(__dirname, 'dist'),
|
|
|
|
host: '0.0.0.0',
|
|
|
|
port: 8888,
|
|
|
|
disableHostCheck: true,
|
|
|
|
},
|
|
|
|
};
|