2020-08-25 22:17:24 +03:00
|
|
|
/*!
|
|
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
* Licensed under the MIT License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
|
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
|
|
|
|
|
|
module.exports = env => {
|
2020-08-26 20:36:25 +03:00
|
|
|
const htmlTemplate = "./src/index.html";
|
2020-08-25 22:17:24 +03:00
|
|
|
const plugins = env && env.prod
|
|
|
|
? [new CleanWebpackPlugin(), new HtmlWebpackPlugin({ template: htmlTemplate })]
|
|
|
|
: [new HtmlWebpackPlugin({ template: htmlTemplate })];
|
|
|
|
|
|
|
|
const mode = env && env.prod
|
|
|
|
? "production"
|
|
|
|
: "development";
|
|
|
|
|
|
|
|
return {
|
|
|
|
devtool: "inline-source-map",
|
|
|
|
entry: {
|
2020-08-26 20:36:25 +03:00
|
|
|
app: "./src/app.ts",
|
2020-08-25 22:17:24 +03:00
|
|
|
},
|
|
|
|
mode,
|
|
|
|
module: {
|
|
|
|
rules: [{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
loader: "ts-loader"
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
filename: "[name].[contenthash].js",
|
|
|
|
},
|
|
|
|
plugins,
|
|
|
|
resolve: {
|
|
|
|
extensions: [".ts", ".js"],
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|