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:

  1. Download and unzip Framework7 GitHub repository to local folder

  2. Install Node.js (if not installed)

  3. 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. rtl: false, // change to true to generate RTL styles
    4. // remove any components you don't need
    5. components: [
    6. // Appbar
    7. 'appbar',
    8. // Modals
    9. 'dialog',
    10. 'popup',
    11. 'login-screen',
    12. 'popover',
    13. 'actions',
    14. 'sheet',
    15. 'toast',
    16. // Loaders
    17. 'preloader',
    18. 'progressbar',
    19. // List Components
    20. 'sortable',
    21. 'swipeout',
    22. 'accordion',
    23. 'contacts-list',
    24. 'virtual-list',
    25. 'list-index',
    26. // Timeline
    27. 'timeline',
    28. // Tabs
    29. 'tabs',
    30. // Panel
    31. 'panel',
    32. // Card
    33. 'card',
    34. // Chip
    35. 'chip',
    36. // Form Components
    37. 'form',
    38. 'input',
    39. 'checkbox',
    40. 'radio',
    41. 'toggle',
    42. 'range',
    43. 'stepper',
    44. 'smart-select',
    45. // Grid
    46. 'grid',
    47. // Pickers
    48. 'calendar',
    49. 'picker',
    50. // Page Components
    51. 'infinite-scroll',
    52. 'pull-to-refresh',
    53. 'lazy',
    54. // Data table
    55. 'data-table',
    56. // FAB
    57. 'fab',
    58. // Searchbar
    59. 'searchbar',
    60. // Messages
    61. 'messages',
    62. 'messagebar',
    63. // Swiper
    64. 'swiper',
    65. // Photo Browser
    66. 'photo-browser',
    67. // Notifications
    68. 'notification',
    69. // Autocomplete
    70. 'autocomplete',
    71. // Tooltip
    72. 'tooltip',
    73. // Gauge
    74. 'gauge',
    75. // Skeleton
    76. 'skeleton',
    77. // Menu
    78. 'menu',
    79. // Color Picker
    80. 'color-picker',
    81. // Tree View
    82. 'treeview',
    83. // WYSIWYG Editor
    84. 'text-editor',
    85. // Elevation
    86. 'elevation',
    87. // Typography
    88. 'typography',
    89. // VI Video Ads
    90. 'vi',
    91. ],
    92. // include/exclude dark theme styles
    93. darkTheme: true,
    94. // include/exclude light theme styles
    95. lightTheme: true,
    96. // include/exclude themes
    97. themes: [
    98. 'ios',
    99. 'md',
    100. 'aurora',
    101. ],
    102. // modify colors
    103. themeColor: '#007aff',
    104. colors: {
    105. red: '#ff3b30',
    106. green: '#4cd964',
    107. blue: '#2196f3',
    108. pink: '#ff2d55',
    109. yellow: '#ffcc00',
    110. orange: '#ff9500',
    111. purple: '#9c27b0',
    112. deeppurple: '#673ab7',
    113. lightblue: '#5ac8fa',
    114. teal: '#009688',
    115. lime: '#cddc39',
    116. deeporange: '#ff6b22',
    117. gray: '#8e8e93',
    118. white: '#ffffff',
    119. black: '#000000',
    120. },
    121. };
    122. module.exports = config;
  7. 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

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';
  3. // Import additional components
  4. import Searchbar from 'framework7/components/searchbar/searchbar.js';
  5. import Calendar from 'framework7/components/calendar/calendar.js';
  6. import Popup from 'framework7/components/popup/popup.js';
  7. // Install F7 Components using .use() method on Framework7 class:
  8. Framework7.use([Searchbar, Calendar, Popup]);
  9. // Init app
  10. var app = new Framework7({/*...*/});

The following components are available for importing (all other components are part of the core):

ComponentPath
Appbarframework7/components/appbar/appbar.js
Dialogframework7/components/dialog/dialog.js
Popupframework7/components/popup/popup.js
LoginScreenframework7/components/login-screen/login-screen.js
Popoverframework7/components/popover/popover.js
Actionsframework7/components/actions/actions.js
Sheetframework7/components/sheet/sheet.js
Toastframework7/components/toast/toast.js
Preloaderframework7/components/preloader/preloader.js
Progressbarframework7/components/progressbar/progressbar.js
Sortableframework7/components/sortable/sortable.js
Swipeoutframework7/components/swipeout/swipeout.js
Accordionframework7/components/accordion/accordion.js
ContactsListframework7/components/contacts-list/contacts-list.js
VirtualListframework7/components/virtual-list/virtual-list.js
ListIndexframework7/components/list-index/list-index.js
Timelineframework7/components/timeline/timeline.js
Tabsframework7/components/tabs/tabs.js
Panelframework7/components/panel/panel.js
Cardframework7/components/card/card.js
Chipframework7/components/chip/chip.js
Formframework7/components/form/form.js
Inputframework7/components/input/input.js
Checkboxframework7/components/checkbox/checkbox.js
Radioframework7/components/radio/radio.js
Toggleframework7/components/toggle/toggle.js
Rangeframework7/components/range/range.js
Stepperframework7/components/stepper/stepper.js
SmartSelectframework7/components/smart-select/smart-select.js
Gridframework7/components/grid/grid.js
Calendarframework7/components/calendar/calendar.js
Pickerframework7/components/picker/picker.js
InfiniteScrollframework7/components/infinite-scroll/infinite-scroll.js
PullToRefreshframework7/components/pull-to-refresh/pull-to-refresh.js
Lazyframework7/components/lazy/lazy.js
DataTableframework7/components/data-table/data-table.js
Fabframework7/components/fab/fab.js
Searchbarframework7/components/searchbar/searchbar.js
Messagesframework7/components/messages/messages.js
Messagebarframework7/components/messagebar/messagebar.js
Swiperframework7/components/swiper/swiper.js
PhotoBrowserframework7/components/photo-browser/photo-browser.js
Notificationframework7/components/notification/notification.js
Autocompleteframework7/components/autocomplete/autocomplete.js
Tooltipframework7/components/tooltip/tooltip.js
Gaugeframework7/components/gauge/gauge.js
Skeletonframework7/components/skeleton/skeleton.js
Menuframework7/components/menu/menu.js
ColorPickerframework7/components/color-picker/color-picker.js
Treeviewframework7/components/treeview/treeview.js
Text Editorframework7/components/text-editor/text-editor.js
Typographyframework7/components/typography/typography.js
Viframework7/components/vi/vi.js

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:

  1. // core
  2. @import url('path/to/node_modules/framework7/framework7.less');
  3. // import only components you need
  4. @import url('path/to/node_modules/framework7/components/searchbar/searchbar.less');
  5. @import url('path/to/node_modules/framework7/components/calendar/calendar.less');
  6. @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');
  3. // import only components you need
  4. @import url('path/to/node_modules/framework7/components/searchbar/searchbar.less');
  5. @import url('path/to/node_modules/framework7/components/calendar/calendar.less');
  6. @import url('path/to/node_modules/framework7/components/popup/popup.less');
  7. // include/exclude themes
  8. @includeIosTheme: true;
  9. @includeMdTheme: true;
  10. @includeAuroraTheme: true;
  11. // include/exclude dark theme
  12. @includeDarkTheme: true;
  13. // include/exclude light theme
  14. @includeLightTheme: true;
  15. // Theme color
  16. @themeColor: #007aff;
  17. // Extra colors
  18. @colors: {
  19. red: #ff3b30;
  20. green: #4cd964;
  21. blue: #2196f3;
  22. pink: #ff2d55;
  23. yellow: #ffcc00;
  24. orange: #ff9500;
  25. purple: #9c27b0;
  26. deeppurple: #673ab7;
  27. lightblue: #5ac8fa;
  28. teal: #009688;
  29. lime: #cddc39;
  30. deeporange: #ff6b22;
  31. gray: #8e8e93;
  32. white: #ffffff;
  33. black: #000000;
  34. };
  35. // change to true to generate RTL styles
  36. @rtl: false;

← Lazy Modules