2019-03-05 16:14:39 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
2019-03-07 17:20:24 +01:00
|
|
|
const path = require("path");
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
2019-03-05 16:14:39 +01:00
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
2019-03-07 17:20:24 +01:00
|
|
|
|
2019-03-05 16:14:39 +01:00
|
|
|
const dev = process.env.NODE_ENV !== "production";
|
2019-03-07 17:20:24 +01:00
|
|
|
const entry = path.join(__dirname, "src", "index.ts");
|
|
|
|
const buildPath = path.join(
|
|
|
|
__dirname,
|
|
|
|
"..",
|
|
|
|
process.env.BUILD_PATH && process.env.BUILD_PATH.length > 0
|
|
|
|
? process.env.BUILD_PATH
|
|
|
|
: "build"
|
|
|
|
);
|
2019-03-05 16:14:39 +01:00
|
|
|
|
2019-01-30 12:06:35 +01:00
|
|
|
module.exports = {
|
2019-03-05 16:14:39 +01:00
|
|
|
mode: dev ? "development" : "production",
|
2019-03-07 17:20:24 +01:00
|
|
|
entry, // Start from this file.
|
2019-03-05 16:14:39 +01:00
|
|
|
output: {
|
2019-03-07 17:20:24 +01:00
|
|
|
path: buildPath, // The files will be created here.
|
2019-04-25 09:13:34 +02:00
|
|
|
// filename: dev ? "vc.[name].min.js" : "vc.[name].[chunkhash:8].min.js"
|
2023-01-09 16:13:54 +01:00
|
|
|
filename: "vc.[name].min.js",
|
|
|
|
assetModuleFilename: "[name][ext]",
|
|
|
|
clean: true
|
2019-03-05 16:14:39 +01:00
|
|
|
},
|
2019-02-11 13:43:04 +01:00
|
|
|
devtool: "source-map",
|
|
|
|
resolve: {
|
|
|
|
extensions: [".ts", ".js", ".json"]
|
|
|
|
},
|
2019-01-30 12:06:35 +01:00
|
|
|
module: {
|
|
|
|
rules: [
|
2019-03-05 16:14:39 +01:00
|
|
|
// Loader for the Typescript compiler.
|
2019-01-30 12:06:35 +01:00
|
|
|
{
|
2023-01-09 17:10:17 +01:00
|
|
|
test: /\.(ts)x?$/,
|
|
|
|
exclude: /node_modules|\.d\.ts$/, // this line as well
|
|
|
|
use: {
|
|
|
|
loader: "ts-loader",
|
|
|
|
options: {
|
|
|
|
compilerOptions: {
|
|
|
|
noEmit: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-05 16:14:39 +01:00
|
|
|
},
|
|
|
|
// This loader builds a main CSS file from all the CSS imports across the files.
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
2023-01-09 16:13:54 +01:00
|
|
|
use: [
|
2019-03-05 16:14:39 +01:00
|
|
|
// https://github.com/webpack-contrib/mini-css-extract-plugin
|
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
options: {
|
2023-01-09 16:13:54 +01:00
|
|
|
//hot: true // if you want HMR - we try to automatically inject hot reloading but if it's not working, add it to the config
|
|
|
|
//reloadAll: true // when desperation kicks in - this is a brute force HMR flag
|
2019-03-05 16:14:39 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
// https://webpack.js.org/loaders/css-loader
|
|
|
|
{
|
|
|
|
loader: "css-loader",
|
|
|
|
options: {
|
|
|
|
sourceMap: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
// To allow the use of file imports. The imported files are transformed into
|
|
|
|
// data uris if they are small enough or it returns a path to the file.
|
|
|
|
// https://webpack.js.org/loaders/url-loader
|
|
|
|
{
|
|
|
|
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
|
2023-01-09 16:13:54 +01:00
|
|
|
type: "asset",
|
|
|
|
generator: {
|
|
|
|
filename: "[name][ext]"
|
2019-03-05 16:14:39 +01:00
|
|
|
}
|
2019-01-30 12:06:35 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2019-03-05 16:14:39 +01:00
|
|
|
plugins: [
|
|
|
|
// Options for the plugin which extract the CSS files to build a main file.
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
// Options similar to the same options in webpackOptions.output
|
|
|
|
// both options are optional
|
2019-04-25 09:13:34 +02:00
|
|
|
// filename: dev ? "vc.[name].css" : "vc.[name].[contenthash:8].css",
|
2023-01-09 16:13:54 +01:00
|
|
|
filename: "vc.[name].css"
|
2019-03-05 16:14:39 +01:00
|
|
|
})
|
|
|
|
],
|
|
|
|
// Static server which runs the playground on npm start.
|
2019-01-30 12:06:35 +01:00
|
|
|
devServer: {
|
|
|
|
open: true,
|
2023-01-09 17:40:50 +01:00
|
|
|
static: path.join(__dirname, "playground")
|
2019-01-30 12:06:35 +01:00
|
|
|
}
|
|
|
|
};
|