Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: moved polygon mask to external plugin (breaking)
build: more webpack tsparticles plugin utilities and configurations
- Loading branch information
1 parent
f4ba397
commit abdfe37
Showing
90 changed files
with
3,175 additions
and
650 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
Oops, something went wrong.