Framework7 Custom Build
Custom Build
Framework7 comes with Gulp builder that allows to build custom library version where you may include only required components/modules. We need the following:
Download and unzip Framework7 GitHub repository to local folder
Install Node.js (if not installed)
Install Gulp (if not installed) by executing the following command in terminal:
$ npm install --global gulp
Now, we need to install required dependencies. Go to the folder with downloaded and unzipped Framework7 repository and execute in terminal:
$ npm install
- Copy
scripts/build-config.js
file to some place in the downloaded folder and rename it let's say toscripts/my-config.js
- Open this file and remove components that you don't need or modify color theme and included colors:
/* my-config.js */ const config = { rtl: false, // change to true to generate RTL styles // remove any components you don't need components: [ // Modals 'dialog', 'popup', 'login-screen', 'popover', 'actions', 'sheet', 'toast', // Loaders 'preloader', 'progressbar', // List Components 'sortable', 'swipeout', 'accordion', 'contacts-list', 'virtual-list', 'list-index', // Timeline 'timeline', // Tabs 'tabs', // Panel 'panel', // Card 'card', // Chip 'chip', // Form Components 'form', 'input', 'checkbox', 'radio', 'toggle', 'range', 'stepper', 'smart-select', // Grid 'grid', // Pickers 'calendar', 'picker', // Page Components 'infinite-scroll', 'pull-to-refresh', // Data table 'data-table', // FAB 'fab', // Searchbar 'searchbar', // Messages 'messages', 'messagebar', // Swiper 'swiper', // Photo Browser 'photo-browser', // Notifications 'notification', // Autocomplete 'autocomplete', // Tooltip 'tooltip', // Gauge 'gauge', // Skeleton 'skeleton', // Color Picker 'color-picker', // Tree View 'treeview', // WYSIWYG Editor 'text-editor', // Pie Chart 'pie-chart', // Area Chart 'area-chart', // Breadcrumbs 'breadcrumbs', // Typography 'typography', ], // include/exclude dark theme styles darkTheme: true, // include/exclude light theme styles lightTheme: true, // include/exclude themes themes: [ 'ios', 'md', ], }; module.exports = config;
Now, we are ready to build custom version of Framework7. We need to execute:
$ npm run build-core:prod -- --config scripts/my-config.js --output path/to/output/folder
That is all. Now you should see newly generated js and css files in specified output folder
ES Modules
If you use bundler like Webpack or Rollup you can use only required Framework7 JS components without that build process and by importing only required components:
// Import core framework
import Framework7 from 'framework7';
// Import additional components
import Searchbar from 'framework7/components/searchbar';
import Calendar from 'framework7/components/calendar';
import Popup from 'framework7/components/popup';
// Install F7 Components using .use() method on Framework7 class:
Framework7.use([Searchbar, Calendar, Popup]);
// Init app
var app = new Framework7({/*...*/});
The following components are available for importing (all other components are part of the core):
Component | Path | |
---|---|---|
Dialog | framework7/components/dialog | |
Popup | framework7/components/popup | |
LoginScreen | framework7/components/login-screen | |
Popover | framework7/components/popover | |
Actions | framework7/components/actions | |
Sheet | framework7/components/sheet | |
Toast | framework7/components/toast | |
Preloader | framework7/components/preloader | |
Progressbar | framework7/components/progressbar | |
Sortable | framework7/components/sortable | |
Swipeout | framework7/components/swipeout | |
Accordion | framework7/components/accordion | |
ContactsList | framework7/components/contacts-list | |
VirtualList | framework7/components/virtual-list | |
ListIndex | framework7/components/list-index | |
Timeline | framework7/components/timeline | |
Tabs | framework7/components/tabs | |
Panel | framework7/components/panel | |
Card | framework7/components/card | |
Chip | framework7/components/chip | |
Form | framework7/components/form | |
Input | framework7/components/input | |
Checkbox | framework7/components/checkbox | |
Radio | framework7/components/radio | |
Toggle | framework7/components/toggle | |
Range | framework7/components/range | |
Stepper | framework7/components/stepper | |
SmartSelect | framework7/components/smart-select | |
Grid | framework7/components/grid | |
Calendar | framework7/components/calendar | |
Picker | framework7/components/picker | |
InfiniteScroll | framework7/components/infinite-scroll | |
PullToRefresh | framework7/components/pull-to-refresh | |
DataTable | framework7/components/data-table | |
Fab | framework7/components/fab | |
Searchbar | framework7/components/searchbar | |
Messages | framework7/components/messages | |
Messagebar | framework7/components/messagebar | |
Swiper | framework7/components/swiper | |
PhotoBrowser | framework7/components/photo-browser | |
Notification | framework7/components/notification | |
Autocomplete | framework7/components/autocomplete | |
Tooltip | framework7/components/tooltip | |
Gauge | framework7/components/gauge | |
Skeleton | framework7/components/skeleton | |
ColorPicker | framework7/components/color-picker | |
Treeview | framework7/components/treeview | |
Text Editor | framework7/components/text-editor | |
Pie Chart | framework7/components/pie-chart | |
Area Chart | framework7/components/area-chart | |
Breadcrumbs | framework7/components/breadcrumbs | |
Typography | framework7/components/typography |
Less.js
Framework7 styles are built with Less.js. If you use Less and NPM in your app/project then you can easily create custom Framework7 stylesheet with only components you need.
Create your own framework7.less
file:
// core
@import 'framework7/less';
// import only components you need
@import 'framework7/components/searchbar/less';
@import 'framework7/components/calendar/less';
@import 'framework7/components/popup/less';
We can go even further and specify Framework7's main color theme and required colors in custom framework7.less
file:
// core
@import 'framework7/less';
// import only components you need
@import 'framework7/components/searchbar/less';
@import 'framework7/components/calendar/less';
@import 'framework7/components/popup/less';
// include/exclude themes
@includeIosTheme: true;
@includeMdTheme: true;
// include/exclude dark theme
@includeDarkTheme: true;
// include/exclude light theme
@includeLightTheme: true;
// Theme color
@themeColor: #007aff;
// Extra colors
@colors: {
red: #ff3b30;
green: #4cd964;
blue: #2196f3;
pink: #ff2d55;
yellow: #ffcc00;
orange: #ff9500;
purple: #9c27b0;
deeppurple: #673ab7;
lightblue: #5ac8fa;
teal: #009688;
lime: #cddc39;
deeporange: #ff6b22;
gray: #8e8e93;
white: #ffffff;
black: #000000;
};
// change to true to generate RTL styles
@rtl: false;