2020-08-24 07:37:43 +03:00
|
|
|
import * as path from 'path';
|
|
|
|
import * as webpack from 'webpack';
|
2020-08-16 00:27:22 +03:00
|
|
|
|
2020-08-24 07:37:43 +03:00
|
|
|
const isProduction = process.env.NODE_ENV === 'production';
|
2020-08-16 00:27:22 +03:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
mode: isProduction ? 'production' : 'development',
|
|
|
|
devtool: 'eval',
|
|
|
|
entry: isProduction
|
|
|
|
? ['./demo/src/index']
|
|
|
|
: [
|
|
|
|
'webpack-dev-server/client?http://localhost:3000',
|
|
|
|
'webpack/hot/only-dev-server',
|
|
|
|
'./demo/src/index',
|
|
|
|
],
|
|
|
|
output: {
|
|
|
|
path: path.join(__dirname, 'demo/static'),
|
|
|
|
filename: 'bundle.js',
|
|
|
|
publicPath: isProduction ? 'static/' : '/static/',
|
|
|
|
},
|
|
|
|
plugins: isProduction ? [] : [new webpack.HotModuleReplacementPlugin()],
|
|
|
|
resolve: {
|
2020-08-24 07:37:43 +03:00
|
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
2020-08-16 00:27:22 +03:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
2020-08-24 07:37:43 +03:00
|
|
|
test: /\.(js|ts)x?$/,
|
2020-08-16 00:27:22 +03:00
|
|
|
loader: 'babel-loader',
|
|
|
|
include: [
|
|
|
|
path.join(__dirname, 'src'),
|
|
|
|
path.join(__dirname, 'demo/src'),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
devServer: isProduction
|
|
|
|
? null
|
|
|
|
: {
|
|
|
|
publicPath: '/static/',
|
|
|
|
port: 3000,
|
|
|
|
contentBase: './demo/',
|
|
|
|
hot: true,
|
|
|
|
stats: {
|
|
|
|
colors: true,
|
|
|
|
},
|
|
|
|
historyApiFallback: true,
|
|
|
|
},
|
|
|
|
};
|