Giter Club home page Giter Club logo

jolt-website's Introduction

webpack_conf

A webpack configuration for webdevs using scss, postcss, html and js.

Based on HtmlWebpackPlugin.

Comes with postcss autoprefixer.

File structure:

The following setup will only work on a specific file structure:

    src
    |_  html
    |   |_  index.html
    |   |_  ....html
    |
    |_  img
    |_  svg
    |_  scss
    |_  css
    |_  js
    |_  vid

    node_modules
    |_  ...

    dist
    |_  index.html
    |_  html
    |   |_  ....html
    |
    |_  img
    |_  svg
    |_  scss
    |_  css
    |_  js
    |_  vid

All the media folders (img, svg, vid) should have their contents placed there directly, without creating subfolders. This is important to ensure the resolve in webpack.config.js is working correctly.

The webpack output will be put into dist/. Webpack will place index.html directly under dist/index.html. All other assets will be placed in the corresponding folder in dist/.

How to code

SASS

Concerning sass-loader and urls

At this time of writing sass-loader does not work with url() references in mixins Problems with url(...). Thats why I added a resolve to webpack.config.js. Therefore it is important that any relative paths in scss files are rewritten to make use of webpack resolve.

Example:

  1. Reference to src/img/... file: url(~img/...). (It doesn't matter how deep you are in the subfolders of src)

Usage of normalize.css

You will find a node module called @csstools/normalize.css after npm install. If you want to use normalize.css, please import it in your scss files:

@import '~@csstools/normalize.css';

HTML

Generating more than one html file

If you have more than one html file (e.g. index.html, file2.html etc.) then you have to create a HtmlWebpackPlugin instance for each file. A comment about how to do this can be found in webpack.config.js.

Cross site anchor tags

References made by cross-site anchor tags can currently not be resolved. Anchor tag relative paths should be relative to the locations the html files are going to have in dist/.

Installation

  1. If you are starting a new project:
git clone https://github.com/benjaminpreiss/webpack_conf.git
  1. Change git origin remote to your github repository:
git remote set-url origin <YOUR-GITHUB-REPO>
  1. Install all npm dependencies according to package.json:
npm install
  1. Configure browserslist in .browserslistrc and specify what browsers you want to support with your project. Example browserslist:
defaults
last 4 versions
  1. Configure htmlhint in .htmlhintrc to fit your needs.

Usage

  1. Start webpack build:
npx webpack
  1. Check js linting:
npx jslint

Recommendations for VS Code

  1. Use eslint extension by Dirk Baeumer (dbaeumer.vscode-eslint)
  2. Use stylelint extension by stylelint (stylelint.vscode-stylelint)
  3. Use htmlhint extension by Mike Kaufmann (mkaufman.htmlhint)

jolt-website's People

Contributors

benjaminpreiss avatar nuggetofwisdom avatar scottwedge avatar

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.