Skip to content

Commit

Permalink
feat: moved polygon mask to external plugin (breaking)
Browse files Browse the repository at this point in the history
build: more webpack tsparticles plugin utilities and configurations
  • Loading branch information
matteobruni committed Sep 23, 2021
1 parent f4ba397 commit abdfe37
Show file tree
Hide file tree
Showing 90 changed files with 3,175 additions and 650 deletions.
3 changes: 2 additions & 1 deletion bundles/full/package.dist.json
Expand Up @@ -72,6 +72,7 @@
"types": "index.d.ts",
"dependencies": {
"tsparticles-engine": "^1.35.1",
"tsparticles-slim": "^1.35.1"
"tsparticles-slim": "^1.35.1",
"tsparticles-plugin-polygon-mask": "^1.35.1"
}
}
20 changes: 11 additions & 9 deletions bundles/full/package.json
Expand Up @@ -74,26 +74,28 @@
"url": "https://github.com/sponsors/matteobruni"
},
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/core": "^7.15.5",
"@types/webpack-env": "^1.16.2",
"@typescript-eslint/eslint-plugin": "^4.29.1",
"@typescript-eslint/parser": "^4.29.1",
"@typescript-eslint/eslint-plugin": "^4.31.2",
"@typescript-eslint/parser": "^4.31.2",
"babel-loader": "^8.2.2",
"copyfiles": "^2.4.1",
"downlevel-dts": "^0.7.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"prettier": "^2.3.2",
"prettier": "^2.4.1",
"rimraf": "^3.0.2",
"terser-webpack-plugin": "^5.1.4",
"typescript": "^4.4.2",
"webpack": "^5.50.0",
"terser-webpack-plugin": "^5.2.4",
"typescript": "^4.4.3",
"webpack": "^5.53.0",
"webpack-bundle-analyzer": "^4.4.2",
"webpack-cli": "^4.8.0"
"webpack-cli": "^4.8.0",
"webpack-tsparticles-plugin": "^1.0.0"
},
"dependencies": {
"tsparticles-engine": "^1.35.1",
"tsparticles-slim": "^1.35.1"
"tsparticles-slim": "^1.35.1",
"tsparticles-plugin-polygon-mask": "^1.35.1"
},
"publishConfig": {
"directory": "dist"
Expand Down
2 changes: 1 addition & 1 deletion bundles/full/src/index.ts
Expand Up @@ -2,7 +2,7 @@ import type { Main } from "tsparticles-engine";
import { loadSlim } from "tsparticles-slim";
import { loadAbsorbersPlugin } from "tsparticles-engine/Plugins/Absorbers/plugin";
import { loadEmittersPlugin } from "tsparticles-engine/Plugins/Emitters/plugin";
import { loadPolygonMaskPlugin } from "tsparticles-engine/Plugins/PolygonMask/plugin";
import { loadPolygonMaskPlugin } from "tsparticles-plugin-polygon-mask";

export function loadFull(tsParticles: Main): void {
loadSlim(tsParticles);
Expand Down
119 changes: 2 additions & 117 deletions bundles/full/webpack.config.js
@@ -1,119 +1,4 @@
const path = require("path");
const TerserPlugin = require("terser-webpack-plugin");
const webpack = require("webpack");
const {BundleAnalyzerPlugin} = require("webpack-bundle-analyzer");

const getEntry = (name, bundle) => {
const obj = {};
const fileName = bundle ? "bundle" : "index";

obj[`tsparticles${name}`] = `./dist/${fileName}.js`;
obj[`tsparticles${name}.min`] = `./dist/${fileName}.js`;

return obj;
}

const getExternals = (bundle) => {
if (bundle) {
return [];
}

return [
{
"tsparticles": {
commonjs: "tsparticles",
commonjs2: "tsparticles",
amd: "tsparticles",
root: "window"
}
},
{
"tsparticles-slim": {
commonjs: "tsparticles-slim",
commonjs2: "tsparticles-slim",
amd: "tsparticles-slim",
root: "window"
}
},
{
"tsparticles-engine": {
commonjs: "tsparticles-engine",
commonjs2: "tsparticles-engine",
amd: "tsparticles-engine",
root: "window"
}
}
];
};

const getConfig = (entry, bannerInput, minBannerInput, dir, bundle) => {
return {
entry: entry,
output: {
path: path.resolve(dir, "dist"),
filename: "[name].js",
libraryTarget: "umd",
globalObject: "this"
},
resolve: {
extensions: [".js", ".json"]
},
externals: getExternals(bundle),
module: {
rules: [
{
// Include ts, tsx, js, and jsx files.
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader"
}
]
},
plugins: [
new webpack.BannerPlugin({
banner: bannerInput,
exclude: /\.min\.js$/
}),
new webpack.BannerPlugin({
banner: minBannerInput,
include: /\.min\.js$/
}),
new BundleAnalyzerPlugin({
openAnalyzer: false,
analyzerMode: "static",
exclude: /\.min\.js$/,
reportFilename: "report.html"
})
],
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
include: /\.min\.js$/,
terserOptions: {
output: {
comments: minBanner
}
},
extractComments: false
})
]
}
};
};

const {loadParticlesBundle} = require("webpack-tsparticles-plugin");
const version = require("./package.json").version;

const banner = `Author : Matteo Bruni
MIT license: https://opensource.org/licenses/MIT
Demo / Generator : https://particles.js.org/
GitHub : https://www.github.com/matteobruni/tsparticles
How to use? : Check the GitHub README
v${version}`;

const minBanner = `tsParticles Preset v${version} by Matteo Bruni`;

module.exports = [
getConfig(getEntry("", false), banner, minBanner, __dirname, false),
getConfig(getEntry(".bundle", true), banner, minBanner, __dirname, true)
];
module.exports = loadParticlesBundle("", "", version, __dirname);
14 changes: 7 additions & 7 deletions bundles/full/yarn.lock
Expand Up @@ -21,7 +21,7 @@
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.15.0.tgz#2dbaf8b85334796cafbb0f5793a90a2fc010b176"
integrity sha512-0NqAC1IJE0S0+lL1SWFMxMkz1pKCNCjI4tr2Zx4LJSXxCLAdr6KyArnY+sno5m3yH9g737ygOyPABDsnXkpxiA==

"@babel/core@^7.15.0":
"@babel/core@^7.15.5":
version "7.15.5"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.15.5.tgz#f8ed9ace730722544609f90c9bb49162dc3bf5b9"
integrity sha512-pYgXxiwAgQpgM1bNkZsDEq85f0ggXMA5L7c+o3tskGMh2BunCI9QUwB9Z4jpvXUOuMdyGKiGKQiRe11VS6Jzvg==
Expand Down Expand Up @@ -304,7 +304,7 @@
resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.16.2.tgz#8db514b059c1b2ae14ce9d7bb325296de6a9a0fa"
integrity sha512-vKx7WNQNZDyJveYcHAm9ZxhqSGLYwoyLhrHjLBOkw3a7cT76sTdjgtwyijhk1MaHyRIuSztcVwrUOO/NEu68Dw==

"@typescript-eslint/eslint-plugin@^4.29.1":
"@typescript-eslint/eslint-plugin@^4.31.2":
version "4.31.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.31.2.tgz#9f41efaee32cdab7ace94b15bd19b756dd099b0a"
integrity sha512-w63SCQ4bIwWN/+3FxzpnWrDjQRXVEGiTt9tJTRptRXeFvdZc/wLiz3FQUwNQ2CVoRGI6KUWMNUj/pk63noUfcA==
Expand All @@ -329,7 +329,7 @@
eslint-scope "^5.1.1"
eslint-utils "^3.0.0"

"@typescript-eslint/parser@^4.29.1":
"@typescript-eslint/parser@^4.31.2":
version "4.31.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.31.2.tgz#54aa75986e3302d91eff2bbbaa6ecfa8084e9c34"
integrity sha512-EcdO0E7M/sv23S/rLvenHkb58l3XhuSZzKf6DBvLgHqOYdL6YFMYVtreGFWirxaU2mS1GYDby3Lyxco7X5+Vjw==
Expand Down Expand Up @@ -1678,7 +1678,7 @@ prelude-ls@^1.2.1:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==

prettier@^2.3.2:
prettier@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.4.1.tgz#671e11c89c14a4cfc876ce564106c4a6726c9f5c"
integrity sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==
Expand Down Expand Up @@ -2013,7 +2013,7 @@ tapable@^2.1.1, tapable@^2.2.0:
resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0"
integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==

terser-webpack-plugin@^5.1.3, terser-webpack-plugin@^5.1.4:
terser-webpack-plugin@^5.1.3, terser-webpack-plugin@^5.2.4:
version "5.2.4"
resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.2.4.tgz#ad1be7639b1cbe3ea49fab995cbe7224b31747a1"
integrity sha512-E2CkNMN+1cho04YpdANyRrn8CyN4yMy+WdFKZIySFZrGXZxJwJP6PMNGGc/Mcr6qygQHUUqRxnAPmi0M9f00XA==
Expand Down Expand Up @@ -2088,7 +2088,7 @@ type-fest@^0.20.2:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4"
integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==

typescript@^4.1.0-dev.20201026, typescript@^4.4.2:
typescript@^4.1.0-dev.20201026, typescript@^4.4.3:
version "4.4.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.3.tgz#bdc5407caa2b109efd4f82fe130656f977a29324"
integrity sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==
Expand Down Expand Up @@ -2170,7 +2170,7 @@ webpack-sources@^3.2.0:
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.1.tgz#251a7d9720d75ada1469ca07dbb62f3641a05b6d"
integrity sha512-t6BMVLQ0AkjBOoRTZgqrWm7xbXMBzD+XDq2EZ96+vMfn3qKgsvdXZhbPZ4ElUOpdv4u+iiGe+w3+J75iy/bYGA==

webpack@^5.50.0:
webpack@^5.53.0:
version "5.53.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.53.0.tgz#f463cd9c6fc1356ae4b9b7ac911fd1f5b2df86af"
integrity sha512-RZ1Z3z3ni44snoWjfWeHFyzvd9HMVYDYC5VXmlYUT6NWgEOWdCNpad5Fve2CzzHoRED7WtsKe+FCyP5Vk4pWiQ==
Expand Down
17 changes: 9 additions & 8 deletions bundles/slim/package.json
Expand Up @@ -74,22 +74,23 @@
"url": "https://github.com/sponsors/matteobruni"
},
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/core": "^7.15.5",
"@types/webpack-env": "^1.16.2",
"@typescript-eslint/eslint-plugin": "^4.29.1",
"@typescript-eslint/parser": "^4.29.1",
"@typescript-eslint/eslint-plugin": "^4.31.2",
"@typescript-eslint/parser": "^4.31.2",
"babel-loader": "^8.2.2",
"copyfiles": "^2.4.1",
"downlevel-dts": "^0.7.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"prettier": "^2.3.2",
"prettier": "^2.4.1",
"rimraf": "^3.0.2",
"terser-webpack-plugin": "^5.1.4",
"typescript": "^4.4.2",
"webpack": "^5.50.0",
"terser-webpack-plugin": "^5.2.4",
"typescript": "^4.4.3",
"webpack": "^5.53.0",
"webpack-bundle-analyzer": "^4.4.2",
"webpack-cli": "^4.8.0"
"webpack-cli": "^4.8.0",
"webpack-tsparticles-plugin": "^1.0.0"
},
"dependencies": {
"tsparticles-engine": "^1.35.1"
Expand Down
119 changes: 2 additions & 117 deletions bundles/slim/webpack.config.js
@@ -1,119 +1,4 @@
const path = require("path");
const TerserPlugin = require("terser-webpack-plugin");
const webpack = require("webpack");
const {BundleAnalyzerPlugin} = require("webpack-bundle-analyzer");

const getEntry = (name, bundle) => {
const obj = {};
const fileName = bundle ? "bundle" : "index";

obj[`tsparticles.${name}`] = `./dist/${fileName}.js`;
obj[`tsparticles.${name}.min`] = `./dist/${fileName}.js`;

return obj;
}

const getExternals = (bundle) => {
if (bundle) {
return [];
}

return [
{
"tsparticles": {
commonjs: "tsparticles",
commonjs2: "tsparticles",
amd: "tsparticles",
root: "window"
}
},
{
"tsparticles-slim": {
commonjs: "tsparticles-slim",
commonjs2: "tsparticles-slim",
amd: "tsparticles-slim",
root: "window"
}
},
{
"tsparticles-engine": {
commonjs: "tsparticles-engine",
commonjs2: "tsparticles-engine",
amd: "tsparticles-engine",
root: "window"
}
}
];
};

const getConfig = (entry, bannerInput, minBannerInput, dir, bundle) => {
return {
entry: entry,
output: {
path: path.resolve(dir, "dist"),
filename: "[name].js",
libraryTarget: "umd",
globalObject: "this"
},
resolve: {
extensions: [".js", ".json"]
},
externals: getExternals(bundle),
module: {
rules: [
{
// Include ts, tsx, js, and jsx files.
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader"
}
]
},
plugins: [
new webpack.BannerPlugin({
banner: bannerInput,
exclude: /\.min\.js$/
}),
new webpack.BannerPlugin({
banner: minBannerInput,
include: /\.min\.js$/
}),
new BundleAnalyzerPlugin({
openAnalyzer: false,
analyzerMode: "static",
exclude: /\.min\.js$/,
reportFilename: "report.html"
})
],
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
include: /\.min\.js$/,
terserOptions: {
output: {
comments: minBanner
}
},
extractComments: false
})
]
}
};
};

const {loadParticlesBundle} = require("webpack-tsparticles-plugin");
const version = require("./package.json").version;

const banner = `Author : Matteo Bruni
MIT license: https://opensource.org/licenses/MIT
Demo / Generator : https://particles.js.org/
GitHub : https://www.github.com/matteobruni/tsparticles
How to use? : Check the GitHub README
v${version}`;

const minBanner = `tsParticles Bubbles Preset v${version} by Matteo Bruni`;

module.exports = [
getConfig(getEntry("slim", false), banner, minBanner, __dirname, false),
getConfig(getEntry("slim.bundle", true), banner, minBanner, __dirname, true)
];
module.exports = loadParticlesBundle("slim", "Slim", version, __dirname);

0 comments on commit abdfe37

Please sign in to comment.