2020-03-27 23:36:14 +01:00
|
|
|
const path = require('path');
|
2020-03-31 01:27:59 +02:00
|
|
|
const webpack = require("webpack");
|
2020-03-27 23:36:14 +01:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
2020-03-31 01:27:59 +02:00
|
|
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
|
|
const ManifestGenerator = require("./webpack/ManifestPlugin");
|
|
|
|
const WorkerPlugin = require('worker-plugin');
|
|
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
2020-03-27 23:36:14 +01:00
|
|
|
|
|
|
|
const isDevelopment = process.env.NODE_ENV === 'development';
|
|
|
|
module.exports = {
|
2020-03-30 13:44:18 +02:00
|
|
|
entry: {
|
|
|
|
//"shared-app": "./shared/js/main.ts"
|
|
|
|
"shared-app": "./web/js/index.ts"
|
|
|
|
},
|
2020-03-27 23:36:14 +01:00
|
|
|
devtool: 'inline-source-map',
|
|
|
|
mode: "development",
|
|
|
|
plugins: [
|
2020-03-31 01:27:59 +02:00
|
|
|
new CleanWebpackPlugin(),
|
2020-03-27 23:36:14 +01:00
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: isDevelopment ? '[name].css' : '[name].[hash].css',
|
|
|
|
chunkFilename: isDevelopment ? '[id].css' : '[id].[hash].css'
|
2020-03-30 13:44:18 +02:00
|
|
|
}),
|
2020-03-31 01:27:59 +02:00
|
|
|
new ManifestGenerator({
|
|
|
|
file: path.join(__dirname, "dist/manifest.json")
|
|
|
|
}),
|
|
|
|
new WorkerPlugin(),
|
|
|
|
//new BundleAnalyzerPlugin()
|
2020-03-30 13:44:18 +02:00
|
|
|
/*
|
|
|
|
new CircularDependencyPlugin({
|
|
|
|
//exclude: /a\.js|node_modules/,
|
|
|
|
failOnError: true,
|
|
|
|
allowAsyncCycles: false,
|
|
|
|
cwd: process.cwd(),
|
2020-03-27 23:36:14 +01:00
|
|
|
})
|
2020-03-30 13:44:18 +02:00
|
|
|
*/
|
2020-03-31 01:27:59 +02:00
|
|
|
new webpack.optimize.AggressiveSplittingPlugin({
|
|
|
|
minSize: 1024 * 128,
|
|
|
|
maxSize: 1024 * 1024
|
|
|
|
})
|
2020-03-27 23:36:14 +01:00
|
|
|
],
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.s[ac]ss$/,
|
|
|
|
loader: [
|
|
|
|
//isDevelopment ? 'style-loader' : MiniCssExtractPlugin.loader,
|
|
|
|
'style-loader',
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
|
|
|
modules: true,
|
|
|
|
sourceMap: isDevelopment
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'sass-loader',
|
|
|
|
options: {
|
|
|
|
sourceMap: isDevelopment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
exclude: /node_modules/,
|
2020-03-27 23:36:57 +01:00
|
|
|
|
|
|
|
loader: [
|
|
|
|
{
|
|
|
|
loader: 'ts-loader',
|
|
|
|
options: {
|
2020-03-30 13:44:18 +02:00
|
|
|
transpileOnly: true
|
2020-03-27 23:36:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2020-03-31 01:27:59 +02:00
|
|
|
}
|
2020-03-27 23:36:14 +01:00
|
|
|
],
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.tsx', '.ts', '.js', ".scss"],
|
2020-03-29 12:54:15 +02:00
|
|
|
alias: {
|
|
|
|
"tc-shared": path.resolve(__dirname, "shared/js"),
|
2020-03-31 01:27:59 +02:00
|
|
|
"tc-backend/web": path.resolve(__dirname, "web/js"),
|
|
|
|
"tc-backend": path.resolve(__dirname, "web/js"),
|
|
|
|
"tc-generated/codec/opus": path.resolve(__dirname, "asm/generated/TeaWeb-Worker-Codec-Opus.js"),
|
2020-03-30 13:44:18 +02:00
|
|
|
//"tc-backend": path.resolve(__dirname, "shared/backend.d"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
externals: {
|
2020-03-31 01:27:59 +02:00
|
|
|
"tc-loader": "window loader"
|
2020-03-27 23:36:14 +01:00
|
|
|
},
|
|
|
|
output: {
|
2020-03-31 01:27:59 +02:00
|
|
|
filename: '[contenthash].js',
|
2020-03-27 23:36:14 +01:00
|
|
|
path: path.resolve(__dirname, 'dist'),
|
2020-03-31 01:27:59 +02:00
|
|
|
publicPath: "js/"
|
2020-03-27 23:36:14 +01:00
|
|
|
},
|
|
|
|
optimization: {
|
2020-03-31 01:27:59 +02:00
|
|
|
splitChunks: { }
|
2020-03-27 23:36:14 +01:00
|
|
|
}
|
|
|
|
};
|