2020-04-22 13:13:33 +00:00
|
|
|
/* eslint-env node */
|
|
|
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
|
|
|
2020-04-19 21:31:59 +00:00
|
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
2020-04-24 20:37:30 +00:00
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
2020-04-25 21:26:20 +00:00
|
|
|
const CaseSensitivePathsPlugin = require("case-sensitive-paths-webpack-plugin");
|
2020-04-25 20:35:27 +00:00
|
|
|
const Webpack = require("webpack");
|
|
|
|
|
2020-04-19 21:31:59 +00:00
|
|
|
const path = require("path");
|
|
|
|
|
2020-04-22 14:24:58 +00:00
|
|
|
const DEVELOPMENT = process.env.NODE_ENV === "development";
|
|
|
|
|
2020-04-25 21:00:50 +00:00
|
|
|
let version = process.env.DRONE_TAG;
|
|
|
|
|
|
|
|
if(!version){
|
|
|
|
version = require('child_process')
|
|
|
|
.execSync("git describe --abbrev=0")
|
|
|
|
.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
version = version.replace("v", "").trim();
|
2020-04-25 20:35:27 +00:00
|
|
|
|
2020-04-19 21:31:59 +00:00
|
|
|
module.exports = {
|
|
|
|
context: path.join(__dirname, "src"),
|
|
|
|
resolve: {
|
|
|
|
extensions: [".js", ".ts", ".tsx"]
|
|
|
|
},
|
|
|
|
entry: ["./index.tsx"],
|
|
|
|
output: {
|
2020-04-24 20:37:30 +00:00
|
|
|
path: path.join(__dirname, "dist/startpage"),
|
2020-04-19 21:31:59 +00:00
|
|
|
filename: "bundle.js"
|
|
|
|
},
|
2020-04-22 14:24:58 +00:00
|
|
|
devtool: DEVELOPMENT ? "source-map" : false,
|
2020-04-19 21:31:59 +00:00
|
|
|
devServer: {
|
2020-04-22 13:13:33 +00:00
|
|
|
contentBase: "./dist",
|
|
|
|
inline: true,
|
2020-04-19 21:31:59 +00:00
|
|
|
host: "localhost",
|
|
|
|
port: 8080,
|
2020-04-22 13:13:33 +00:00
|
|
|
stats: "errors-only",
|
|
|
|
liveReload: true,
|
|
|
|
watchContentBase: true
|
2020-04-19 21:31:59 +00:00
|
|
|
},
|
2020-04-23 22:00:45 +00:00
|
|
|
watchOptions: {
|
|
|
|
ignored: ['dist/**', 'node_modules/**']
|
|
|
|
},
|
2020-04-19 21:31:59 +00:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.(ts|tsx)$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
loader: "ts-loader"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.s[ac]ss$/i,
|
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
"css-loader",
|
|
|
|
"sass-loader",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png|jpg|gif|svg)$/,
|
|
|
|
loader: "file-loader",
|
|
|
|
options: {
|
|
|
|
name: "assets/img/[name].[ext]?[hash]"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
filename: "index.html",
|
|
|
|
template: "index.html",
|
2020-04-22 14:24:58 +00:00
|
|
|
hash: true,
|
|
|
|
minify: !DEVELOPMENT
|
2020-04-19 21:31:59 +00:00
|
|
|
}),
|
2020-04-24 20:37:30 +00:00
|
|
|
new MiniCssExtractPlugin(),
|
|
|
|
new CopyWebpackPlugin([
|
2020-04-25 20:35:27 +00:00
|
|
|
{
|
|
|
|
from: "manifest.json",
|
|
|
|
to: "..",
|
|
|
|
transform(content) {
|
|
|
|
return content.toString().replace("$VERSION", version);
|
|
|
|
}
|
2020-04-24 20:37:30 +00:00
|
|
|
}
|
2020-04-25 20:35:27 +00:00
|
|
|
]),
|
|
|
|
new Webpack.DefinePlugin({
|
|
|
|
VERSION: JSON.stringify(version),
|
2020-04-25 21:26:20 +00:00
|
|
|
}),
|
|
|
|
new CaseSensitivePathsPlugin()
|
2020-04-19 21:31:59 +00:00
|
|
|
]
|
|
|
|
};
|