Giter VIP home page Giter VIP logo

bootpack / bootpack Goto Github PK

View Code? Open in Web Editor NEW
30.0 4.0 7.0 12.75 MB

Create multi-page websites using bootstrap for development and webpack for task running.

License: MIT License

JavaScript 14.73% CSS 60.62% HTML 24.65%
template website-template bootstrap-template webpack-starter-template boilerplate boilerplate-template website-builder webpack bootstrap webpack4 bootstrap4 website-template-bootstrap

bootpack's Introduction

bootpack · GitHub release Build Status GitHub license PRs Welcome GitHub stars

bootpack

bootpack is a boilerplate template to create multi-page websites using bootstrap for development and webpack for task running. View the latest version at https://bootpack.github.io/bootpack/.

Bootstrap + Webpack = ♥

  • Just Develop: 4 steps to get started. Launch a dev server with live reloading.
  • Pre-Configured: A pre-configured webpack config simplifies overcomplicated build processes.
  • Predictable File Output: Keep your CSS where you want it; out of your JavaScript files! The dist directory will closely match the src directory.
  • Minified Files: JavaScript and CSS is minified and output as single files.
  • Compressed Resources: JS, CSS, fonts, images and favicons are gzipped for maximum compression.
  • Dev and Production Builds: Build the project in development mode with sourcemapping enabled or production mode.
  • Development Tools: Generate & compress images + more tools to ease web development.
  • Built-In Tests: Lint JavaScript and CSS files with one command.

Table of Contents

Getting Started

Prerequisites

Use bootpack as a template (Option 1)

Using bootpack as template is the recommended method.

  1. To get started, click the "Use this template" button at the top of this repository.
    Use this template button

  2. After clicking the "Use this template" button, you will be asked to enter a name for a new repostiory. This repository will be generated with all of the bootpack repository’s files and folders.

  3. Next, simply perform the following commands in your terminal to get started, replacing [USERNAME]/[REPOSITORY_NAME] with the location and repository names you chose in the previous step.

git clone https://github.com/[USERNAME]/[REPOSITORY_NAME].git
npm install
npm run build
npm start

Fork/Clone bootpack (Option 2)

bootpack can also be forked into your own repository and cloned or cloned directly using the following commands.

git clone https://github.com/bootpack/bootpack.git
npm install
npm run build
npm start
  • Navigate to http://localhost:8080 in a browser.
  • Save a file in the project to refresh the browser.
  • Press ctrl+c in the terminal to stop serving.

Usage

Build

npm run build - Creates the project in production mode (minified) and outputs to the dist directory.
npm run watch - Creates the project in development mode (unminified). This mode watches for changes and outputs to the dist directory.
npm start - Creates the project in development mode (unminified). This mode watches for changes, outputs to the dist directory and live reloades the page.

Test

npm run test - Runs lint tests (+ additional unit and e2e tests can be added here as needed)
npm run lint - Runs npm run lint:js and npm run lint:styles
npm run lint:js - Runs eslint test on src/*/*.js files
npm run lint:css - Runs stylelint test on src/css/*.css files
npm run lint:scss - Runs stylelint test on src/scss/*.scss files
npm run lint:styles - Runs npm run lint:css and npm run lint:scss

Tools

npm run compress:images

  • Optimizes images in the images directory, saves original images to images-original.
  • Run before building or during watch. Only the images directory will be copied to the dist directory.
  • Edit tools/image-compress.js to change the image compress. See: https://www.npmjs.com/package/compress-images for settings

npm run generate:images width ### height ###

  • Creates a placeholder.jpg image in the images directory
  • Replace ### with a numeric value representing wwidth and height. If no width/height is specified, the placeholder will default to 800px x 600px.

About

Webpack 4

Webpack: Builds

The webpack build creates a dist directory that closely mimics the src directory.

  • In production mode, the dist directory contains files that are minified & compressed.
  • In development mode, files are kept unminified with sourcemapping turned on as needed & no compression output.
  • Webpack server is available to speed up development via live browser refreshes on code change while preserving the ability to inspect the dist directory.

The src directory contains starter files to get your project off the ground quickly.

Webpack: Process

The webpack task runner builds the site with the following commands:

  • npm run build will build production.
  • npm run watch builds development mode and watches for file changes.
  • npm start builds development mode, watches for file changes, opens the browser and refreshes when files change.
  1. The dist directory is cleaned on first built or modified on change (npm start or npm run watch).
  2. src/**/*.html is copied to dist/**/*.html
  3. Favicons are generated and injected into the dist index.html file from the src/favicon.png file.
  4. Bootstrap components are imported into the index.js and output to dist/index.js.
  5. CSS/SCSS files in src/css/ and src/scss/ are bundled together, minified and output to dist/styles.css.
  6. Images and fonts are copied from src/images -> dist/images and src/fonts -> dist/fonts.
  7. Files are compressed with gzip compression.

Bootstrap 4

Bootstrap: SCSS Files

Bootstrap 4 is imported into scss/boostrap.scss via @import "~bootstrap/scss/*bootstrap*"; import rules. Optional components can be excluded by commenting out the @import rules in this file (recommended to minimize bundle size).

SCSS/CSS Overrides & Custom Styles:
  • scss/variables.scss is included to override all of bootstrap's built in variables.
  • scss/custom.scss is included to add custom scss to the project.
  • css/custom.css is included to add custom css to the project.
  • css/fonts.css is included to import local fonts into the project. Open Sans has been included as an example.

Bootstrap: JS Files

Bootstap 4 is imported in the index.js file via bootstrap.bundle which contains the full bootstrap JavaScript plus the popper.js tooltip dependency. Below the bootstrap.bundle import, comments contain other methods to import bootstrap. End-users may choose to import bootstrap.bundle, bootstrap, or individual components (recommended to minimize bundle size).

File Structure

src file structure

|-css/
|--custom.css
|--fonts.css
|-fonts/
|--OpenSans/
|----[font_styles]/
|-images/
|--[images]
|-js
|--index.js
|-scss/
|--boostrap.scss
|--custom.scss
|--variables.scss
|-templates/
|--[templates]/
|----index.html
|-favicon.png
|-index.html

dist file structure

/* All files compressed, minified & gzipped */
|-css
|--index.css
|--index.css.gz
|-fonts/
|--OpenSans/
|----[font_styles]/
|-images/
|--[images]
|-js
|--index.js
|--index.js.gz
|-templates/
|--[templates]/
|----index.html
|----index.html.gz
|-[favicons]
|-index.html
|-index.html.gz

Contributing

Please contribute using Gitflow. Create a feature branch, add commits, and open a pull request.

Support

Please open an issue for support.

bootpack's People

Contributors

dependabot-preview[bot] avatar greenkeeper[bot] avatar joeykanaly avatar zachtrice avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bootpack's Issues

Remove unused css on production build

Is your feature request related to a problem? Please describe.
There is a lot of unused css which could be removed in production builds.

Describe the solution you'd like
The likely solution will be to use uncss in a custom node script. This would run after webpack-build production. It would remove the styles.gz file, analyze the styles.css file, remove the css and then create a new gzip stylesheet.

Describe alternatives you've considered

Additional context
N/A

Ability to generate multiple pages

The webpack configuration currently is tailored to creating a single page. Allowing users to set up multiple pages right away, or at the very least, provide documentation on how to add multiple pages, would be useful.

Add ability to generate multiple placeholder images

The ability to output an image 1 at a time is a bit limiting, sometimes it would be nice to define a set (array?) or image sizes to be output all at once. This might work best as a separate file (JSON? comma delimited list?).

Example

{
    "images": [
        {
            "title": "banner",
            "width": 1200, 
            "height": 320, 
            "quality": 100
        },
        {
            "title": "thumbnail",
            "width": 80, 
            "height": 80, 
            "quality": 100
        }
    ]
}

Support multiple CSS entry points

Is your feature request related to a problem? Please describe.
Right now only a single entry point is used. This means that only 1 compressed CSS file is used on every page.

Describe the solution you'd like
There should be a clear and easy approach to setting up multiple CSS files for different pages.

Describe alternatives you've considered
Might need to look for an alternative to mini-css-extract-plugin

An in-range update of webpack is breaking the build 🚨

The devDependency webpack was updated from 4.35.3 to 4.36.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

webpack is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Release Notes for v4.36.0

Features

  • SourceMapDevToolPlugin append option now supports the default placeholders in addition to [url]
  • Arrays in resolve and parser options (Rule and Loader API) support backreferences with "..." when overriding options.
Commits

The new version differs by 42 commits.

  • 95d21bb 4.36.0
  • aa1216c Merge pull request #9422 from webpack/feature/dot-dot-dot-merge
  • b3ec775 improve merging of resolve and parsing options
  • 53a5ae2 Merge pull request #9419 from vankop/remove-valid-jsdoc-rule
  • ab75240 Merge pull request #9413 from webpack/dependabot/npm_and_yarn/ajv-6.10.2
  • 0bdabf4 Merge pull request #9418 from webpack/dependabot/npm_and_yarn/eslint-plugin-jsdoc-15.5.2
  • f207cdc remove valid jsdoc rule in favour of eslint-plugin-jsdoc
  • 31333a6 chore(deps-dev): bump eslint-plugin-jsdoc from 15.3.9 to 15.5.2
  • 036adf0 Merge pull request #9417 from webpack/dependabot/npm_and_yarn/eslint-plugin-jest-22.8.0
  • 37d4480 Merge pull request #9411 from webpack/dependabot/npm_and_yarn/simple-git-1.121.0
  • ce2a183 chore(deps-dev): bump eslint-plugin-jest from 22.7.2 to 22.8.0
  • 0beeb7e Merge pull request #9391 from vankop/create-hash-typescript
  • bf1a24a #9391 resolve super call discussion
  • bd7d95b #9391 resolve discussions, AbstractMethodError
  • 4190638 chore(deps): bump ajv from 6.10.1 to 6.10.2

There are 42 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Add a gh-pages deployment script

Describe the solution you'd like
A few options worth exploring:

  • gh-pages to make deploying to github.io a breeze. I have used this in other repositories.
  • ftp-deploy - This might make the most sense. Since bootpack is desigend for web designer/developers who are use to working with FTP servers.
  • Custom ssh deploy script

Create npm script to build bootstrap examples

Description

Create an npm script that can build bootstrap example templates

Would build these examples with only the required imports needed. (Plus have a flag to include full BS4 code).
https://getbootstrap.com/docs/4.0/examples/

Thinking something long the lines of:
npm run build generate:bs4 -- generates bare bs4 template with mimum imports
npm run generate:bs4-album --full -- generates bs4 album template with full bs4 import included

Investigate CSS compressing out of order

Description

I noticed that bootstrap was overriding my declarations when targeting the same selector. Further investigation reveled bootstrap was coming after my custom css even though the @imports were in the correct order within main.css.

Webpack fails to watch files

Describe the bug
Currently webpack is not properly watching changes to the html files.

Expected behavior

  • npm run watch should use webpack-dev-server.
  • Template paths should be added to index.js and detect changes if NODE_ENV=development
  • A npm run build:dev option should be added to debug non-server output

Add hashes to dist file names for cache busting

Is your feature request related to a problem? Please describe.
Minified css files need to be cache busted by outputting the min files with a hash.

Describe the solution you'd like
Add a hash to the dist/main.css file

Describe alternatives you've considered
None

Additional context
None

Output current version in console

Is your feature request related to a problem? Please describe.
Output the version number in the console (terminal & browser console) to easily find the version being ran.

Describe the solution you'd like

  • Output version to terminal on build
  • Output version in browser console

Add CI/CD

Add CI/CD. Most likely this will be Travis CI but worth exploring other options

Favicons incorrectly linked within subpages

Describe the bug
The favicon relative path within the subpages is not updated when injected into the html.

Additional context
Since the original favicon package I used was no longer being actively supported, I created another favicon package here: https://github.com/bootpack/favicons-plugin to update old dependencies and fix this issue.

Using a newer version of loader-utils and performing better checks against the publicPath should resolve this issue. That work will be referenced here: bootpack/favicons-plugin#1

Note: We are also not setting the publicPath in our webpack config for various reasons. This may change in the future. Setting publicPath currently to / would allow this package to work properly with webpack-dev-server but would break when opening dist files locally. Addiionally, the css paths on subpages breaks when setting the publicPath to / but rel paths are injected properly when this field is omitted.

Deploy dist directory to github pages

Is your feature request related to a problem? Please describe.
Automatically deploy the dist directory to bootpack.github.io. This will allow users to see what the template will look like when built.

Describe the solution you'd like
Remove the separate bootpack.github.io repository and utilize git worktree add dist gh-pages to push the contents of the dist directory to the gh-pages branch

Tasks

Favicons only generate half the time

Describe the bug
When running npm start, npm run build or npm run watch, favicon generation only occurs if the dist directory does not already contain favicons. If the dist directory does contain favicons from a previous build, the next build will not have any icons output.

To Reproduce
Steps to reproduce the behavior:

  1. Run npm start
  2. Observe favicons in dist directory
  3. Run npm start
  4. Observe no favicons in dist directory

Expected behavior
Favicons generate on every build.

Create GitHub action to automate release process (gh-pages branch)

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Add favicons for progress web apps

Description

Currently there are no favicons in the application. There should be default favicons for all the PWA platforms (Android, iOS, Windows, etc.)

Import individual bootstrap components & use full build by default

Is your feature request related to a problem? Please describe.
Bootstrap is not being imported into index,js and main.css does not include all bootstrap sass files.

Describe the solution you'd like
main.css and index.js should have the full bootstrap bundles imported by default but also individual components commented out below so that advanced users can import only what is needed.

jQuery global $ should also be exposed via the webpack config file

Describe alternatives you've considered
None

Additional context
None

Add image optimization tool

Is your feature request related to a problem? Please describe.
It would be nice to have a method for auto optimizing images in the src folder and piping these to the dist folder

Describe the solution you'd like
compress-images images is a good npm package that can handle this. I have used this dependency in the past to create custom image optimization pipelines. It can optimize gif, png, svg, and jpeg via a multitude of engines one can choose.

Improve bootstrap component import paths

Describe the bug
Currently bootstrap components are not handled correctly. The boostrap/js/src is imported so dependency imports work but it is not being babelified. Imports should be switched to point to the bootstrap/js/dist then, include jQuery slim, popper, and bootstrap util in webpack.

Fix duplicate Travis CI checks

Describe the bug
4 Travis CI checks are occuring when there should only be 1 for the branch and 1 for creating a pull request.

Expected behavior
Only use "Branch" and "Pull Request" checks.

Screenshots
screenshot_9

Add Favicon generator

Description

Incorporate a node.js favicon generator.

Performing npm generator:favicon would build all the progress web app favicons and extract them to a "favicons" src folder. When the source is ran through webpack, all the favicons would be placed and gzipped into the root of the dist folder. There should be options to turn on/off different sizes.

Here is the first library I found for a node.js favicon generator: https://github.com/evilebottnawi/favicons Other dependency libraries should be researched (or decide if this needs written from scratch).

Add icon libraries using build flags

Is your feature request related to a problem? Please describe.
Investigate the possibility of adding a icon font generator.

Describe the solution you'd like
icomoon cli tool

Describe alternatives you've considered
Font Awesome 5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.