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:
1. $ npm install --global gulp
4. Now, we need to install required dependencies. Go to the folder with downloaded and unzipped Framework7 repository and execute in terminal:
1. $ npm install
5. Copy scripts/build-config.js file to some place in the downloaded folder and rename it let’s say to scripts/my-config.js
6. Open this file and remove components that you don’t need or modify color theme and included colors:
``` 1. / my-config.js / 2. const config = { 3. target: 'universal', 4. rtl: false, // change to true to generate RTL styles
- // remove any components you don't need
- components: [
- 'dialog',
- 'popup',
- 'login-screen',
- 'popover',
- 'actions',
- 'sheet',
- 'toast',
- 'preloader',
- 'progressbar',
- 'sortable',
- 'swipeout',
- 'accordion',
- 'contacts-list',
- 'virtual-list',
- 'timeline',
- 'tabs',
- 'panel',
- 'card',
- 'chip',
- 'form',
- 'input',
- 'checkbox',
- 'radio',
- 'toggle',
- 'range',
- 'stepper',
- 'smart-select',
- 'grid',
- 'calendar',
- 'picker',
- 'infinite-scroll',
- 'pull-to-refresh',
- 'lazy',
- 'data-table',
- 'fab',
- 'searchbar',
- 'messages',
- 'messagebar',
- 'swiper',
- 'photo-browser',
- 'notification',
- 'autocomplete',
- 'tooltip',
- 'gauge',
- 'vi',
- 'typography',
- ],
- // include/exclude dark theme styles
- darkTheme: true,
- // include/exclude themes
- themes: [
- 'ios',
- 'md',
- ],
- // modify colors
- ios: {
- themeColor: '#007aff',
- colors: {
- red: '#ff3b30',
- green: '#4cd964',
- blue: '#007aff',
- pink: '#ff2d55',
- yellow: '#ffcc00',
- orange: '#ff9500',
- gray: '#8e8e93',
- white: '#ffffff',
- black: '#000000',
- },
- },
- md: {
- themeColor: '#2196f3',
- colors: {
- red: '#f44336',
- green: '#4caf50',
- blue: '#2196f3',
- pink: '#e91e63',
- yellow: '#ffeb3b',
- orange: '#ff9800',
- gray: '#9e9e9e',
- white: '#ffffff',
- black: '#000000',
- },
- },
-
};
-
module.exports = config; ```
- Now, we are ready to build custom version of Framework7. We need to execute:
1. $ npm run build-core:prod -- --config scripts/my-config.js --output path/to/output/folder
8. That is all. Now you should see newly generated js and css files in specified output folder
9. If you are in hurry and want to see how its working then do follow step 1 to 4
1. $ npm run build-core:dev
The result is available in build/ folder. 10. To build production version of Framework7:
```
1. $ npm run build-core:prod
```
Production version will be available in dist/ folder.
-
Run Kitchen Sink with development environment
1. $ npm run core:dev12. Run Kitchen Sink with Production environment1. $ npm run core:prod13. Kitchen Sink is liveVisit <http://localhost:3000/kitchen-sink/core/> From Youre Browser
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:
1. // Import core framework
2. import Framework7 from 'framework7';
4. // Import additional components
5. import Searchbar from 'framework7/components/searchbar/searchbar.js';
6. import Calendar from 'framework7/components/calendar/calendar.js';
7. import Popup from 'framework7/components/popup/popup.js';
9. // Install F7 Components using .use() method on Framework7 class:
10. Framework7.use([Searchbar, Calendar, Popup]);
12. // Init app
13. 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/dialog.js |
|
| Popup | framework7/components/popup/popup.js |
|
| LoginScreen | framework7/components/login-screen/login-screen.js |
|
| Popover | framework7/components/popover/popover.js |
|
| Actions | framework7/components/actions/actions.js |
|
| Sheet | framework7/components/sheet/sheet.js |
|
| Toast | framework7/components/toast/toast.js |
|
| Preloader | framework7/components/preloader/preloader.js |
|
| Progressbar | framework7/components/progressbar/progressbar.js |
|
| Sortable | framework7/components/sortable/sortable.js |
|
| Swipeout | framework7/components/swipeout/swipeout.js |
|
| Accordion | framework7/components/accordion/accordion.js |
|
| ContactsList | framework7/components/contacts-list/contacts-list.js |
|
| VirtualList | framework7/components/virtual-list/virtual-list.js |
|
| ListIndex | framework7/components/list-index/list-index.js |
|
| Timeline | framework7/components/timeline/timeline.js |
|
| Tabs | framework7/components/tabs/tabs.js |
|
| Panel | framework7/components/panel/panel.js |
|
| Card | framework7/components/card/card.js |
|
| Chip | framework7/components/chip/chip.js |
|
| Form | framework7/components/form/form.js |
|
| Input | framework7/components/input/input.js |
|
| Checkbox | framework7/components/checkbox/checkbox.js |
|
| Radio | framework7/components/radio/radio.js |
|
| Toggle | framework7/components/toggle/toggle.js |
|
| Range | framework7/components/range/range.js |
|
| Stepper | framework7/components/stepper/stepper.js |
|
| SmartSelect | framework7/components/smart-select/smart-select.js |
|
| Grid | framework7/components/grid/grid.js |
|
| Calendar | framework7/components/calendar/calendar.js |
|
| Picker | framework7/components/picker/picker.js |
|
| InfiniteScroll | framework7/components/infinite-scroll/infinite-scroll.js |
|
| PullToRefresh | framework7/components/pull-to-refresh/pull-to-refresh.js |
|
| Lazy | framework7/components/lazy/lazy.js |
|
| DataTable | framework7/components/data-table/data-table.js |
|
| Fab | framework7/components/fab/fab.js |
|
| Searchbar | framework7/components/searchbar/searchbar.js |
|
| Messages | framework7/components/messages/messages.js |
|
| Messagebar | framework7/components/messagebar/messagebar.js |
|
| Swiper | framework7/components/swiper/swiper.js |
|
| PhotoBrowser | framework7/components/photo-browser/photo-browser.js |
|
| Notification | framework7/components/notification/notification.js |
|
| Autocomplete | framework7/components/autocomplete/autocomplete.js |
|
| Tooltip | framework7/components/tooltip/tooltip.js |
|
| Gauge | framework7/components/gauge/gauge.js |
|
| Vi | framework7/components/vi/vi.js |
|
| Typography | framework7/components/typography/typography.js |
Less.js
Framework7 styles are build 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:
1. // core
2. @import url('path/to/node_modules/framework7/framework7.less');
4. // import only components you need
5. @import url('path/to/node_modules/framework7/components/searchbar/searchbar.less');
6. @import url('path/to/node_modules/framework7/components/calendar/calendar.less');
7. @import url('path/to/node_modules/framework7/components/popup/popup.less');
We can go even further and specify Framework7’s main color theme and required colors in custom framework7.less file:
1. // core
2. @import url('path/to/node_modules/framework7/framework7.less');
4. // import only components you need
5. @import url('path/to/node_modules/framework7/components/searchbar/searchbar.less');
6. @import url('path/to/node_modules/framework7/components/calendar/calendar.less');
7. @import url('path/to/node_modules/framework7/components/popup/popup.less');
9. // include/exclude themes
10. @includeIosTheme: true;
11. @includeMdTheme: true;
13. // include/exclude dark theme
14. @includeDarkTheme: true;
16. // iOS theme color
17. @themeColorIos: #007aff;
18. // MD theme color
19. @themeColorMd: #2196f3;
21. // Extra colors for iOS theme
22. @colorsIos: red #ff3b30, green #4cd964, blue #007aff, pink #ff2d55, yellow #ffcc00, orange #ff9500, gray #8e8e93, white #ffffff, black #000000;
24. // Extra colors for MD theme
25. @colorsMd: red #f44336, green #4caf50, blue #2196f3, pink #e91e63, yellow #ffeb3b, orange #ff9800, gray #9e9e9e, white #ffffff, black #000000;
27. // change to true to generate RTL styles
28. @rtl: false;
