2
0
mirror of https://github.com/tenrok/maska.git synced 2026-06-20 20:00:34 +03:00

♻️ use rollup instead of webpack

allow build process to generate esm and umd packages
This commit is contained in:
Vinicius Reis
2020-03-10 14:10:05 -03:00
parent 63aea135cd
commit 636a46cbc0
4 changed files with 4818 additions and 32 deletions
+10 -7
View File
@@ -15,22 +15,25 @@
}, },
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"serve": "rimraf dist && webpack --watch", "serve": "rimraf dist && NODE_ENV=development rollup -c --watch",
"build": "rimraf dist && webpack -p", "build": "rimraf dist && NODE_ENV=production rollup -c && NODE_ENV=production DISABLE_BABEL=yes rollup -c",
"test": "jest", "test": "jest",
"lint": "standard 'src/**'" "lint": "standard 'src/**'"
}, },
"module": "src/index.js", "main": "dist/maska.umd.js",
"module": "dist/maska.esm.js",
"unpkg": "dist/maska.umd.js",
"jsdelivr": "dist/maska.umd.js",
"devDependencies": { "devDependencies": {
"@babel/core": "^7.7.5", "@babel/core": "^7.7.5",
"@babel/preset-env": "^7.7.5", "@babel/preset-env": "^7.7.5",
"babel-jest": "^24.9.0", "babel-jest": "^24.9.0",
"babel-loader": "^8.0.6",
"jest": "^24.9.0", "jest": "^24.9.0",
"rimraf": "^3.0.0", "rimraf": "^3.0.0",
"standard": "^14.3.1", "rollup": "^2.0.2",
"webpack": "^4.41.2", "rollup-plugin-babel": "^4.4.0",
"webpack-cli": "^3.3.10" "rollup-plugin-terser": "^5.3.0",
"standard": "^14.3.1"
}, },
"browserslist": "> 0.25%, ie 11", "browserslist": "> 0.25%, ie 11",
"babel": { "babel": {
+54
View File
@@ -0,0 +1,54 @@
import babel from 'rollup-plugin-babel';
import { terser } from "rollup-plugin-terser";
const { version } = require('./package.json')
const isProduction = process.env.NODE_ENV === 'production'
const useBabel = process.env.DISABLE_BABEL !== 'yes'
const banner = `/*!
* maska v${version}
* (c) 2019-${(new Date()).getFullYear()} Alexander Shabunevich
* Released under the MIT License.
*/`
const getDistFolder = (fileName = '') => `dist/${useBabel ? '' : 'es6/'}${fileName}`
const makeFileName = (format) => getDistFolder(`maska.${format}.js`)
const makeOutputConfig = (format = true) => {
return {
banner,
format,
file: makeFileName(format),
name: 'Maska'
}
}
const plugins = [
useBabel && babel({
exclude: 'node_modules/**'
}),
isProduction && terser()
].filter(Boolean)
export default {
input: 'src/index.js',
plugins,
output: [
{
...makeOutputConfig('esm')
},
{
...makeOutputConfig('umd'),
exports: 'named',
},
{
...makeOutputConfig('umd'),
file: getDistFolder('maska.js'),
exports: 'named',
},
],
watch: {
exclude: 'node_modules/**'
}
};
-25
View File
@@ -1,25 +0,0 @@
const prod = process.env.NODE_ENV === 'production'
module.exports = {
mode: prod ? 'production' : 'development',
output: {
filename: 'maska.js',
library: 'Maska',
libraryTarget: 'umd',
umdNamedDefine: true
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
}
}
+4754
View File
File diff suppressed because it is too large Load Diff