Skip to content

Commit

Permalink
chore: cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
hexxone committed Nov 6, 2022
1 parent 9092ce9 commit 6ffe0dd
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 100 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"scripts": {
"tsc": "tsc",
"prepcopy": "copyfiles -u 1 -V \"./src/**/*.glsl\" \"./dist/tsc/\"",
"dbg": "yarn prepcopy && tsc && webpack && webpack serve",
"prod": "yarn prepcopy && tsc && webpack --env production && webpack serve --env production",
"dbg": "webpack && webpack serve",
"prod": "webpack --env production && webpack serve --env production",
"lint": "eslint ./src/we_utils/src/cthree/ --ext js,ts,jsx,tsx --fix"
},
"repository": {
Expand Down Expand Up @@ -49,7 +49,6 @@
"eslint-plugin-react": "^7.27.1",
"file-loader": "^6.2.0",
"fork-ts-checker-webpack-plugin": "^6.2.5",
"ink-docstrap": "^1.3.2",
"null-loader": "^4.0.1",
"prettier": "^2.5.0",
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/we_utils
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
"we_utils/*": ["src/we_utils/*"],
"three.ts/*": ["src/we_utils/src/three.ts/*"]
},
"noEmit": true,
"target": "ES2021",
"module": "ES2020",
"moduleResolution": "Node",
"esModuleInterop": true,
"sourceMap": false,
"sourceMap": true,
"removeComments": true,
"baseUrl": ".",
"noImplicitAny": false,
Expand All @@ -21,6 +22,6 @@
},
"types": ["*.d.ts"],
"include": ["./src/**/*.ts"],
"exclude": ["**/*.asc"],
"exclude": ["**/*.asc", "node_modules", "src/**/*.spec.ts", "src/we_utils/docs"],

}
100 changes: 78 additions & 22 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
/* eslint-disable no-undef */
/* eslint-disable @typescript-eslint/no-var-requires */
/**
* Webpack build config for AudiOrbits.
* @author hexxone / https://hexx.one
*
* @license
* Copyright (c) 2022 hexxone All rights reserved.
* Licensed under the GNU GENERAL PUBLIC LICENSE.
* See LICENSE file in the project root for full license information.
*
* Webpack build config for AudiOrbits.
* Probably not a good example to start from :D
*/
/* eslint-disable no-undef */
/* eslint-disable @typescript-eslint/no-var-requires */

const path = require("path");

Expand All @@ -17,26 +23,34 @@ const BundleAnalyzerPlugin =
// custom plugins
const OfflinePlugin = require("./src/we_utils/src/offline/OfflinePlugin");
const WascBuilderPlugin = require("./src/we_utils/src/wasc-worker/WascBuilderPlugin");
const RenamerPlugin = require("./src/we_utils/src/renamer/RenamerPlugin");
// const RenamerPlugin = require("./src/we_utils/src/renamer/RenamerPlugin");

module.exports = (env) => {
const prod = env.production || false;
const stringMode = prod ? "production" : "development";

return {
mode: stringMode,
entry: "./dist/tsc/AudiOrbi.js",
entry: {
ao: {
import: "./src/AudiOrbi.ts",
},
},
// compile target
// target: ["web", "es6", "es2020"],
output: {
chunkFormat: "module",
path: path.resolve(__dirname, "dist", stringMode),
publicPath: "/",
library: "ao",
libraryTarget: "commonjs",
filename: "ao.js",
publicPath: "dist/" + stringMode,
library: {
name: "ao",
type: "var", // window
},
// libraryTarget: "commonjs",
// filename: "ao.js",
filename: "[name].js",
chunkFilename: "[name].js",
globalObject: "this",
chunkFilename: (_pathData) => "ao.[id].js",
},
// remove dead code
optimization: {
Expand All @@ -47,11 +61,11 @@ module.exports = (env) => {
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
terserOptions: {
// ecma: 2020,
parse: {},
compress: {
unsafe: prod,
hoist_funs: prod,
},
// parse: {},
// compress: {
// unsafe: prod,
// hoist_funs: prod,
// },
format: {
comments: false,
},
Expand All @@ -62,15 +76,16 @@ module.exports = (env) => {
regex: /_(private|internal)_/, // the same prefixes like for custom transformer
},
},
module: false,
module: true,
toplevel: true,
sourceMap: false,
keep_fnames: !prod,
// keep_fnames: !prod,
keep_classnames: !prod,
},
extractComments: false,
}),
],
chunkIds: "deterministic",
chunkIds: "size",
concatenateModules: true,
moduleIds: "size",
mangleExports: "size",
Expand All @@ -82,7 +97,40 @@ module.exports = (env) => {
devtool: false,
module: {
rules: [
// JS loader
// loader for workers...
// {
// test: /\.worker\.js$/i,
// loader: "src/we_utils/src/worker-loader-fork/src/index.js",
// options: {
// esModule: true,
// filename: "asdasd.foo.js",
// chunkFilename: "sdf.custom.js",
// },
// },
// loader for Typescript
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/,
options: {
compiler: "typescript", // ttypescript
transpileOnly: true,
// getCustomTransformers: (program) => {
// return {
// before: prod
// ? [
// propertiesRenameTransformer(program, {
// entrySourceFiles: ["main.ts"],
// reserved: ["a", "b", "c", "d", "w", "x", "y", "z", "min", "max"],
// // noImplicitAny: true,
// }),
// ]
// : [],
// };
// },
},
},
// Process any JS outside of the app with Babel.
{
test: /\.jsx?$/, // If you are using TypeScript: /\.tsx?$/
include: path.resolve(__dirname, "src"),
Expand All @@ -107,15 +155,23 @@ module.exports = (env) => {
},
],
},
resolveLoader: {
alias: {
"worker-loader": path.resolve(
__dirname,
"./src/we_utils/src/worker-loader-fork/dist"
),
},
},
resolve: {
extensions: [".tsx", ".ts", ".js", ".glsl"],
// plugins: [new TsconfigPathsPlugin({ configFile: "./tsconfig.json" })],

alias: {
"we_utils/src": path.resolve(__dirname, "./dist/tsc/we_utils/src"),
"we_utils/src": path.resolve(__dirname, "./src/we_utils/src"),
"three.ts/src": path.resolve(
__dirname,
"./dist/tsc/we_utils/src/three.ts/src"
"./src/we_utils/src/three.ts/src"
),
// reverse mapping shaders (dont get copied by tsc)
// "fragment/*.glsl": path.resolve(__dirname, "./src/we_utils/src/three/shader/fragment"),
Expand Down Expand Up @@ -144,7 +200,7 @@ module.exports = (env) => {
// will create a list of all app-files.
// this list is used to cache the app offline in browser.
new OfflinePlugin({
staticdir: "dist/tsc",
staticdir: __dirname + "\\public",
outfile: "offlinefiles.json",
extrafiles: ["/"],
pretty: !prod,
Expand Down
Loading

0 comments on commit 6ffe0dd

Please sign in to comment.