123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- const path = require("path");
- const glob = require("glob");
- const webpack = require("webpack");
- const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
- function resolve (dir) {
- return path.join(__dirname, dir)
- }
- function getDevFiles() {
- const files = glob.sync(path.resolve("./Assets") + "/**/*.@(ts|js)", {
- ignore: [
- "**/*/_Editor/**/*",
- "**/*.d.ts",
- ]
- });
- return files;
- }
- function getEditorFiles() {
- const files = glob.sync( resolve("./Assets") + "/**/*.@(ts|js)", {
- ignore: [
- "**/*.d.ts",
- ]
- });
- return files;
- }
- function getEntry() {
- const entry = {};
- const devFiles = getDevFiles();
- const editorFiles = getEditorFiles();
- if (devFiles.length > 0) {
- entry["rogue-engine-user-scripts"] = devFiles;
- }
- if (editorFiles.length > 0) {
- entry["rogue-editor-user-scripts"] = {
- import: editorFiles,
- dependOn: "rogue-engine-user-scripts",
- }
- }
- return entry;
- }
- module.exports = {
- mode: "development",
- entry: getEntry(),
- output: {
- path: path.resolve(__dirname, "./dist"),
- filename: "[name].js",
- library: "[name]",
- libraryTarget: "umd",
- },
- externals: {
- "rogue-engine": {
- commonjs: "rogue-engine",
- commonjs2: "rogue-engine",
- amd: "rogue-engine",
- root: "rogue-engine"
- },
- "rogue-editor": {
- commonjs: "rogue-editor",
- commonjs2: "rogue-editor",
- amd: "rogue-editor",
- root: "rogue-editor"
- },
- three: {
- commonjs: "three",
- commonjs2: "three",
- amd: "three",
- root: "three"
- },
- },
- resolve: {
- extensions: [".ts", ".js", ".json", "*"],
- modules: [
- resolve("node_modules"),
- resolve("_Rogue")
- ],
- alias: {
- "Assets": resolve("Assets"),
- "rogue-engine": resolve("_Rogue/rogue-engine"),
- "@RE": path.join(__dirname, './Assets/rogue_packages')
- },
- fallback: { "path": false, "fs": false }
- },
- module: {
- rules: [
- {
- test: /\.(js|ts)$/u,
- exclude: [/node_modules/, /_Rogue\/test/, /Assets\/test/, /\.d.ts?$/],
- use: {
- loader: "esbuild-loader",
- options: {
- loader: 'ts',
- target: "es2020",
- keepNames: true,
- },
- },
- }
- ]
- },
- devServer: {
- historyApiFallback: true,
- noInfo: false,
- overlay: true,
- disableHostCheck: true,
- clientLogLevel: "warning"
- },
- watchOptions: {
- aggregateTimeout: 200
- },
- performance: {
- hints: false
- },
- devtool: "source-map",
- plugins: [new ForkTsCheckerWebpackPlugin()]
- }
- if (process.env.NODE_ENV === "production") {
- module.exports.devtool = "source-map";
- module.exports.plugins = (module.exports.plugins || []).concat([
- new webpack.DefinePlugin({
- "process.env": {
- NODE_ENV: '"production"'
- }
- }),
- new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
-
- new webpack.LoaderOptionsPlugin({
- minimize: false
- }),
- ]);
- }
|