thednp / bootstrap.native

Bootstrap components build with Typescript
http://thednp.github.io/bootstrap.native/
MIT License
1.7k stars 177 forks source link

Customs Builds #359

Closed madeInLagny closed 4 years ago

madeInLagny commented 4 years ago

Hello, I want to build the dropdown module only. I downloaded the code and ran node build.js --bs_version 4 --minify --only dropdown from root. I got the following error: Cannot find module 'C:\Users\...\bootstrap.native-master\build.js What am I missing ?

cvaize commented 4 years ago

I would do it the other way, if I already have a configured webpack then I would just import the module import Dropdown from './components/dropdown-native.js' or if I want to build a bundle, I would comment out all the other modules and run the npm run build command. And used the build result from the dist folder image

thednp commented 4 years ago

@madeInLagny we replaced all build tools with rollup and the wiki is out of date.

Stick around, the current build tools will have a new update very soon.

thednp commented 4 years ago

@madeInLagny I have a new build script, currently working on it's logic to make it more flexible.

Example src/index.custom.js

import {initCallback,removeDataAPI} from './util/callbacks.js'  // OPTIONAL if you use your own init scripting
import {componentsInit} from './util/globals.js' // OPTIONAL if you use your own init scripting
import {version as Version} from './../package.json'
import { one } from './util/event.js'

import Alert from './components/alert-native.js'
// add more components you need HERE

// OPTIONAL if you use your own init scripting
componentsInit.Alert = [ Alert, '[data-dismiss="alert"]']  
// add other components similarly here

// bulk initialize all components
// OPTIONAL if you use your own init scripting
document.body ? initCallback() : one( document, 'DOMContentLoaded', initCallback );  

export default {
  Alert,

  initCallback, // OPTIONAL if you use your own init scripting
  removeDataAPI, // OPTIONAL if you use your own init scripting
  componentsInit, // OPTIONAL if you use your own init scripting
  Version
}

And the CLI script

npm run custom INPUTFILE:src/index.custom.js,OUTPUTFILE:dist/bootstrap-native-custom.js,MIN:false,FORMAT:umd

How about that?

I'm now currently working on a way to include ONLY util functions that are used by requested components and not ALL by default.

Cheers

thednp commented 4 years ago

@madeInLagny and @cvaize the new build script is now online, check it out.

I've updated the above guide accordingly and will link to it as a temporary guide for future queries.

Talk to you soon.

picasticks commented 4 years ago

@thednp, thanks for the updated build script and explanation, it works great for me.