merge bs4 and bs5 rollup config
This commit is contained in:
parent
7664c3ad49
commit
151dd5ed6b
|
|
@ -17,7 +17,7 @@
|
|||
"js-compile": "rollup --config src/build/rollup.config.js --sourcemap",
|
||||
"js-minify": "terser --config-file src/build/terser.config.json --output js/theme.min.js js/theme.js",
|
||||
"js-bs4": "npm-run-all js-compile-bs4 js-minify-bs4",
|
||||
"js-compile-bs4": "rollup --config src/build-bootstrap4/rollup.config.js --sourcemap",
|
||||
"js-compile-bs4": "npm run js-compile -- BS4",
|
||||
"js-minify-bs4": "terser --config-file src/build-bootstrap4/terser.config.json --output js/theme-bootstrap4.min.js js/theme-bootstrap4.js",
|
||||
"watch": "npm-run-all --parallel watch-run-*",
|
||||
"watch-bs": "npm-run-all --parallel bs watch-run-*",
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const path = require( 'path' );
|
||||
const { babel } = require( '@rollup/plugin-babel' );
|
||||
const { nodeResolve } = require( '@rollup/plugin-node-resolve' );
|
||||
const multi = require( '@rollup/plugin-multi-entry' );
|
||||
const banner = require( '../build/banner.js' );
|
||||
|
||||
const fileDest = 'theme-bootstrap4.js';
|
||||
const external = [ 'jquery' ];
|
||||
const plugins = [
|
||||
babel( {
|
||||
browserslistEnv: 'bs4',
|
||||
// Include the helpers in the bundle, at most one copy of each
|
||||
babelHelpers: 'bundled',
|
||||
} ),
|
||||
nodeResolve(),
|
||||
multi(),
|
||||
];
|
||||
const globals = {
|
||||
jquery: 'jQuery', // Ensure we use jQuery which is always available even in noConflict mode
|
||||
'popper.js': 'Popper',
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
input: [
|
||||
path.resolve( __dirname, '../js/bootstrap4.js' ),
|
||||
path.resolve( __dirname, '../js/skip-link-focus-fix.js' ),
|
||||
path.resolve( __dirname, '../js/custom-javascript.js' ),
|
||||
],
|
||||
output: {
|
||||
banner,
|
||||
file: path.resolve( __dirname, `../../js/${ fileDest }` ),
|
||||
format: 'umd',
|
||||
globals,
|
||||
name: 'understrap',
|
||||
},
|
||||
external,
|
||||
plugins,
|
||||
};
|
||||
|
|
@ -1,19 +1,46 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
const path = require( 'path' );
|
||||
const { babel } = require( '@rollup/plugin-babel' );
|
||||
const { nodeResolve } = require( '@rollup/plugin-node-resolve' );
|
||||
const commonjs = require( '@rollup/plugin-commonjs' );
|
||||
const multi = require( '@rollup/plugin-multi-entry' );
|
||||
const replace = require( '@rollup/plugin-replace' );
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
const banner = require( './banner.js' );
|
||||
|
||||
const fileDest = 'theme.js';
|
||||
// Determine if we want to build for Bootstrap v4 or v5.
|
||||
const BS4 = process.argv[ process.argv.length - 1 ] === 'BS4';
|
||||
|
||||
// Populate Bootstrap version specific variables.
|
||||
let bsVersion = 5;
|
||||
let bsSrcFile = 'bootstrap.js';
|
||||
let fileDest = 'theme.js';
|
||||
let globals = {
|
||||
jquery: 'jQuery', // Ensure we use jQuery which is always available even in noConflict mode
|
||||
'@popperjs/core': 'Popper',
|
||||
};
|
||||
if ( BS4 ) {
|
||||
// Adjustmets for Bootstrap version 4.
|
||||
bsVersion = 4;
|
||||
bsSrcFile = 'bootstrap4.js';
|
||||
fileDest = 'theme-bootstrap4.js';
|
||||
delete globals[ '@popperjs/core' ];
|
||||
Object.assign( globals, { 'popper.js': 'Popper' } );
|
||||
}
|
||||
|
||||
const external = [ 'jquery' ];
|
||||
|
||||
const plugins = [
|
||||
babel( {
|
||||
browserslistEnv: 'bs5',
|
||||
// Include the helpers in the bundle, at most one copy of each
|
||||
browserslistEnv: `bs${ bsVersion }`,
|
||||
// Include the helpers in the bundle, at most one copy of each.
|
||||
babelHelpers: 'bundled',
|
||||
} ),
|
||||
replace( {
|
||||
|
|
@ -24,14 +51,10 @@ const plugins = [
|
|||
commonjs(),
|
||||
multi(),
|
||||
];
|
||||
const globals = {
|
||||
jquery: 'jQuery', // Ensure we use jQuery which is always available even in noConflict mode
|
||||
'@popperjs/core': 'Popper',
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
input: [
|
||||
path.resolve( __dirname, '../js/bootstrap.js' ),
|
||||
path.resolve( __dirname, `../js/${ bsSrcFile }` ),
|
||||
path.resolve( __dirname, '../js/skip-link-focus-fix.js' ),
|
||||
path.resolve( __dirname, '../js/custom-javascript.js' ),
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in New Issue