Framework7 Custom Build
Download and unzip Framework7 GitHub repository to local folder
Install (if not installed)
Install Gulp (if not installed) by executing the following command in terminal:
Now, we need to install required dependencies. Go to the folder with downloaded and unzipped Framework7 repository and execute in terminal:
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 = {
target: 'universal',
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',
'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;
That is all. Now you should see newly generated js and css files in specified output folder
If you are in hurry and want to see how its working then do follow step 1 to 4
$ npm run build-core:dev
The result is available in build/ folder.
To build production version of Framework7:
$ npm run build-core:prod
Production version will be available in dist/ folder.
Run Kitchen Sink with development environment
-
$ npm run core:prod
Kitchen Sink is live
Visit http://localhost:3000/kitchen-sink/core/ From Youre Browser
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/searchbar.js';
import Calendar from 'framework7/components/calendar/calendar.js';
import Popup from 'framework7/components/popup/popup.js';
// 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):
Framework7 styles are build with . 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 url('path/to/node_modules/framework7/framework7.less');
// import only components you need
@import url('path/to/node_modules/framework7/components/searchbar/searchbar.less');
@import url('path/to/node_modules/framework7/components/calendar/calendar.less');
@import url('path/to/node_modules/framework7/components/popup/popup.less');
// include/exclude themes
@includeIosTheme: true;
@includeMdTheme: true;
// include/exclude dark theme
@includeDarkTheme: true;
// iOS theme color
@themeColorIos: #007aff;
// MD theme color
@themeColorMd: #2196f3;
// Extra colors for iOS theme
@colorsIos: red #ff3b30, green #4cd964, blue #007aff, pink #ff2d55, yellow #ffcc00, orange #ff9500, gray #8e8e93, white #ffffff, black #000000;
// Extra colors for MD theme
@colorsMd: red #f44336, green #4caf50, blue #2196f3, pink #e91e63, yellow #ffeb3b, orange #ff9800, gray #9e9e9e, white #ffffff, black #000000;
@rtl: false;