Skip to content

Commit

Permalink
feat: update builds to include dev builds
Browse files Browse the repository at this point in the history
  • Loading branch information
martinalbert committed Oct 31, 2024
1 parent 1205812 commit 3488632
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 25 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"node": ">=18.17.1"
},
"scripts": {
"build": "webpack",
"build": "webpack --env production",
"build-dev": "webpack --env development",
"run-dev": "cd tests && python3 -m http.server",
"build-dev": "webpack && uglifyjs ./dist/butter.js -c -m -o ./tests/lib/butter.min.js",
"test": "npm run build && npm run test:all",
"test:all": "npm run jest",
"test:watch": "npm run jest --watch",
Expand Down
80 changes: 57 additions & 23 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,96 @@
import * as url from 'url';
import * as url from "url";
import path from "path";
import webpack from "webpack";
import TerserPlugin from "terser-webpack-plugin";

const __dirname = url.fileURLToPath(new URL(".", import.meta.url));

const __dirname = url.fileURLToPath(new URL('.', import.meta.url));

const commonConfig = {
devtool: 'source-map', // Enable source maps
const productionConfig = {
mode: "production",
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
compress: true,
mangle: true,
sourceMap: true,
},
extractComments: false
}),
],
},
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1
})
maxChunks: 1,
}),
],
}
};

const developmentConfig = {
mode: "development",
devtool: 'inline-source-map',
optimization: {
minimize: false, // No minification in development
},
};

export default [
// UMD Build
{
entry: './lib/butter.js',
mode: "production",
...productionConfig,
entry: "./lib/butter.js",
output: {
filename: 'butter.umd.js',
filename: "butter.umd.js",
globalObject: "this",
library: {
name: 'Butter',
type: 'umd',
name: "Butter",
type: "umd",
},
path: path.resolve(__dirname, 'dist')
path: path.resolve(__dirname, "dist"),
},
...commonConfig
},
// ES Module Build
{
entry: './lib/butter.js',
mode: "production",
...productionConfig,
entry: "./lib/butter.js",
output: {
filename: 'butter.esm.js',
filename: "butter.esm.js",
library: {
type: 'module'
type: "module",
},
path: path.resolve(__dirname, 'dist')
path: path.resolve(__dirname, "dist"),
},
experiments: {
outputModule: true,
},
...commonConfig
}
},
// UMD Build - Development
{
...developmentConfig,
entry: "./lib/butter.js",
output: {
filename: "butter.umd.dev.js",
globalObject: "this",
library: {
name: "Butter",
type: "umd",
},
path: path.resolve(__dirname, "dist"),
},
},
// ES Module Build - Development
{
...developmentConfig,
entry: "./lib/butter.js",
output: {
filename: "butter.esm.dev.js",
library: {
type: "module",
},
path: path.resolve(__dirname, "dist"),
},
experiments: {
outputModule: true,
},
},
];

0 comments on commit 3488632

Please sign in to comment.