-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update builds to include dev builds
- Loading branch information
1 parent
1205812
commit 3488632
Showing
2 changed files
with
59 additions
and
25 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
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, | ||
}, | ||
}, | ||
]; |