2020-08-31 00:49:06 +03:00
|
|
|
import * as path from 'path';
|
|
|
|
import * as webpack from 'webpack';
|
|
|
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
|
|
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
|
|
|
|
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
|
|
|
|
import pkg from '../../package.json';
|
2018-12-22 03:10:49 +03:00
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
const isProduction = process.env.NODE_ENV === 'production';
|
2018-12-22 03:10:49 +03:00
|
|
|
|
|
|
|
module.exports = {
|
2019-01-09 03:06:21 +03:00
|
|
|
mode: process.env.NODE_ENV || 'development',
|
2019-01-10 21:51:14 +03:00
|
|
|
entry: isProduction
|
|
|
|
? ['./demo/src/js/index']
|
|
|
|
: [
|
|
|
|
'webpack-dev-server/client?http://localhost:3000',
|
|
|
|
'webpack/hot/only-dev-server',
|
2020-08-08 23:26:39 +03:00
|
|
|
'./demo/src/js/index',
|
2019-01-10 21:51:14 +03:00
|
|
|
],
|
2018-12-22 03:10:49 +03:00
|
|
|
output: {
|
|
|
|
path: path.join(__dirname, 'demo/dist'),
|
2020-08-08 23:26:39 +03:00
|
|
|
filename: 'js/bundle.js',
|
2018-12-22 03:10:49 +03:00
|
|
|
},
|
2020-08-31 00:49:06 +03:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.(js|ts)x?$/,
|
|
|
|
loader: 'babel-loader',
|
|
|
|
include: [
|
|
|
|
path.join(__dirname, '../../src'),
|
|
|
|
path.join(__dirname, '../src/js'),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
|
|
},
|
2018-12-22 03:10:49 +03:00
|
|
|
plugins: [
|
2020-08-08 22:46:01 +03:00
|
|
|
new CleanWebpackPlugin(),
|
2018-12-22 03:10:49 +03:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
inject: true,
|
|
|
|
template: 'demo/src/index.html',
|
2020-08-08 23:26:39 +03:00
|
|
|
package: pkg,
|
2018-12-22 03:10:49 +03:00
|
|
|
}),
|
2020-08-31 00:49:06 +03:00
|
|
|
new ForkTsCheckerWebpackPlugin({
|
|
|
|
typescript: {
|
|
|
|
configFile: 'demo/tsconfig.json',
|
2020-08-08 23:26:39 +03:00
|
|
|
},
|
|
|
|
}),
|
2020-08-09 01:04:46 +03:00
|
|
|
].concat(isProduction ? [] : [new webpack.HotModuleReplacementPlugin()]),
|
2019-01-10 21:51:14 +03:00
|
|
|
devServer: isProduction
|
2020-08-02 03:45:57 +03:00
|
|
|
? {}
|
2019-01-10 21:51:14 +03:00
|
|
|
: {
|
|
|
|
quiet: false,
|
|
|
|
port: 3000,
|
|
|
|
hot: true,
|
|
|
|
stats: {
|
|
|
|
chunkModules: false,
|
2020-08-08 23:26:39 +03:00
|
|
|
colors: true,
|
2019-01-10 21:51:14 +03:00
|
|
|
},
|
2020-08-08 23:26:39 +03:00
|
|
|
historyApiFallback: true,
|
|
|
|
},
|
2020-08-31 00:49:06 +03:00
|
|
|
devtool: 'eval-source-map',
|
2018-12-22 03:10:49 +03:00
|
|
|
};
|