Files
mybb-april-fools/webpack.config.js
T
2023-03-28 01:27:30 +04:00

78 lines
1.8 KiB
JavaScript

// Generated using webpack-cli https://github.com/webpack/webpack-cli
const path = require("path");
const webpack = require("webpack");
const BomPlugin = require('webpack-utf8-bom');
const { exec } = require('node:child_process');
const isProduction = process.env.NODE_ENV == "production";
const config = {
entry: "./src/main.ts",
output: {
path: path.resolve(__dirname, "dist"),
filename: () => ('april-fools' + (isProduction ? '.min' : '') + '.js'),
},
plugins: [
new BomPlugin(true),
{
apply: (compiler) => {
compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => {
exec('./upload.sh', (err, stdout, stderr) => {
if (stdout) process.stdout.write(stdout);
if (stderr) process.stderr.write(stderr);
console.log("Uploaded.");
});
});
}
}
// Add your plugins here
// Learn more about plugins from https://webpack.js.org/configuration/plugins/
],
module: {
rules: [
{
test: /\.(ts|tsx)$/i,
loader: "ts-loader",
exclude: ["/node_modules/"],
},
{
test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
type: "asset",
},
// Add your rules for custom modules here
// Learn more about loaders from https://webpack.js.org/loaders/
],
},
resolve: {
extensions: [".tsx", ".ts", ".jsx", ".js", "..."],
},
externals: {
jquery: 'jQuery',
},
};
module.exports = () => {
if (isProduction) {
config.mode = "production";
} else {
config.mode = "development";
}
return config;
};
/*
{
"compilerOptions": {
"module": "AMD",
"lib": ["es2017", "dom"],
"rootDir": "./src/",
"outFile": "dist/april-fools.js",
"moduleResolution": "nodenext",
"esModuleInterop": true
},
"files": [
"src/main.ts"
]
}
*/