All Projects → vedees → Webpack Template

vedees / Webpack Template

Licence: mit
Webpack 4 template. Vue, Babel 7v, Sass / css / postcss (autoprefixer & css-nano & css-mqpacker)

Projects that are alternatives of or similar to Webpack Template

Tris Webpack Boilerplate
A Webpack boilerplate for static websites that has all the necessary modern tools and optimizations built-in. Score a perfect 10/10 on performance.
Stars: ✭ 1,016 (+272.16%)
Mutual labels:  webpack4, scss
Vue Cli Multipage Bootstrap
vue-cli-multipage-bootstrap demo with vue2+vue-router+vuex+bootstrap+markdown for learning vue2.0
Stars: ✭ 105 (-61.54%)
Mutual labels:  webpack4, vuex
Egg Vue Webpack Boilerplate
Egg Vue Server Side Render (SSR) / Client Side Render (CSR)
Stars: ✭ 1,302 (+376.92%)
Mutual labels:  webpack4, vuex
Vue Admin Webapp
this is a admin project
Stars: ✭ 673 (+146.52%)
Mutual labels:  webpack4, vuex
Vue 2 Webpack 4 Boilerplate
Ready to use Vue 2+ project with webpack 4 configuration for development and production
Stars: ✭ 142 (-47.99%)
Mutual labels:  webpack4, vuex
Easy Vue
Learn vueJS Easily 👻
Stars: ✭ 896 (+228.21%)
Mutual labels:  webpack4, vuex
Webpack4.x
webpack4.x详细配置步骤
Stars: ✭ 103 (-62.27%)
Mutual labels:  webpack4, scss
Vue Cnode
🔥Vue.js打造一个开源的CNode社区。CNode by Vue.js
Stars: ✭ 249 (-8.79%)
Mutual labels:  vuex, scss
163music
🎵163 music web app built with Vue 2.6, server side render, webpack 4
Stars: ✭ 139 (-49.08%)
Mutual labels:  webpack4, vuex
Webpack Pug Scss Boilerplate
📂 Webpack 4 based boilerplate for building apps
Stars: ✭ 135 (-50.55%)
Mutual labels:  webpack4, scss
Cordova Template Framework7 Vue Webpack
Framework7 - Vue - Webpack Cordova Template with Webpack Dev Server and Hot Module Replacement
Stars: ✭ 630 (+130.77%)
Mutual labels:  webpack4, vuex
Vue Element Admin
🎉 A magical vue admin https://panjiachen.github.io/vue-element-admin
Stars: ✭ 73,044 (+26656.04%)
Mutual labels:  webpack4, vuex
New Bee
开源社区 vue + springBoot - 前后分离微服务的最佳实践
Stars: ✭ 619 (+126.74%)
Mutual labels:  webpack4, vuex
Html Sass Babel Webpack Boilerplate
Webpack 4 + Babel + ES6 + SASS + HTML Modules + Livereload
Stars: ✭ 35 (-87.18%)
Mutual labels:  webpack4, scss
Vue Cms
基于 Vue 和 ElementUI 构建的一个企业级后台管理系统
Stars: ✭ 415 (+52.01%)
Mutual labels:  webpack4, vuex
Vue Mpc
multiple pages (multiple entries) based on vue-cli3.x(基于vue-cli3.x创建的多页面应用,每个页面入口又可以创建自己的vue-router)
Stars: ✭ 97 (-64.47%)
Mutual labels:  webpack4, scss
Vue Chat
👥Vue全家桶+Socket.io+Express/Koa2打造一个智能聊天室。
Stars: ✭ 887 (+224.91%)
Mutual labels:  vuex, scss
Tic Tac Vue
A simple Tic-Tac-Toe game written in Vue.
Stars: ✭ 29 (-89.38%)
Mutual labels:  vuex, scss
Nicelinks Vue Client
🐬 很棒的 Web 应用——倾城之链(NICE LINKS),基于 Vue2.*(Webpack、Es6、Element-ui)所构建
Stars: ✭ 133 (-51.28%)
Mutual labels:  webpack4, vuex
Shopify Webpack Themekit
Shopify development tool using webpack and themekit
Stars: ✭ 157 (-42.49%)
Mutual labels:  webpack4, scss

Webpack Template

Webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset.

Author: To code | Youtube guide in Russian

Build Setup:

# Download repository:
git clone https://github.com/vedees/webpack-template webpack-template

# Go to the app:
cd webpack-template

# Install dependencies:
npm install

# Server with hot reload at http://localhost:8081/
npm run dev

# Output will be at dist/ folder
npm run build

Project Structure:

  • src/index.html - main app HTML
  • src/assets/scss - put custom app SCSS styles here. Don't forget to import them in index.js
  • src/assets/css - the same as above but CSS here. Don't forget to import them in index.js
  • src/assets/img - put images here. Don't forget to use correct path: assets/img/some.jpg
  • src/js - put custom app scripts here
  • src/index.js - main app file where you include/import all required libs and init app
  • src/components - folder with custom .vue components
  • src/store - app store for vue
  • static/ - folder with extra static assets that will be copied into output folder

Settings:

Main const:

Easy way to move all files. Default:

const PATHS = {
  // Path to main app dir
  src: path.join(__dirname, '../src'),
  // Path to Output dir
  dist: path.join(__dirname, '../dist'),
  // Path to Second Output dir (js/css/fonts etc folder)
  assets: 'assets/'
}

Customize:

Change any folders:

const PATHS = {
  // src must be src
  src: path.join(__dirname, '../src'),
  // dist to public
  dist: path.join(__dirname, '../public'),
  // assets to static
  assets: 'static/'
}

Import Another libs:

  1. Install libs
  2. Import libs in ./index.js
// React example
import React from 'react'
// Bootstrap example
import Bootstrap from 'bootstrap/dist/js/bootstrap.min.js'
import 'bootstrap/dist/js/bootstrap.min.js'

Import only SASS or CSS libs:

  1. Install libs
  2. Go to /assets/scss/utils/libs.scss
  3. Import libs in node modules
// Sass librarys example:
@import '../../node_modules/spinners/stylesheets/spinners';
// CSS librarys example:
@import '../../node_modules/flickity/dist/flickity.css';

Import js files:

  1. Create another js module in ./js/ folder
  2. Import modules in ./js/index.js file
// another js file for example
import './common.js'

HTML Dir Folder:

Default:

  • .html dir: ./src
  • Configurations: in ./build/webpack.base.conf.js
const PAGES_DIR = PATHS.src

Usage: All files must be created in the ./src folder. Example:

./src/index.html
./src/about.html

Change HTML Default Dir Folder:

Example for ./src/pages:

  1. Create folder for all html files in ./src. Be like: ./src/pages
  2. Change ./build/webpack.base.conf.js const PAGES_DIR:
// Old path
// const PAGES_DIR = PATHS.src

// Your new path
const PAGES_DIR = `${PATHS.src}/pages`
  1. Rerun webpack dev server

Usage: All files must be created in the ./src/pages folder. Example:

./src/pages/index.html
./src/pages/about.html

Create Another HTML Files:

Default:

Automatic creation any html pages:

  1. Create another html file in ./src (main folder)
  2. Open new page http://localhost:8081/about.html (Don't forget to RERUN dev server) See more - commit

Second method:

Manual (not Automaticlly) creation any html pages (Don't forget to RERUN dev server and COMMENT lines above)

  1. Create another html file in ./src (main folder)
  2. Go to ./build/webpack.base.conf.js
  3. Comment lines above (create automaticlly html pages)
  4. Create new page in html:
    new HtmlWebpackPlugin({
      template: `${PAGES_DIR}/index.html`,
      filename: './index.html',
      inject: true
    }),
    new HtmlWebpackPlugin({
      template: `${PAGES_DIR}/another.html`,
      filename: './another.html',
      inject: true
    }),
  1. Open new page http://localhost:8081/about.html (Don't forget to RERUN dev server)

Third method: (BEST)

Сombine the first method and the second. Example:

    ...PAGES.map(page => new HtmlWebpackPlugin({
      template: `${PAGES_DIR}/${page}`,
      filename: `./${page}`
    })),
    new HtmlWebpackPlugin({
      template: `${PAGES_DIR}/about/index.html`,
      filename: './about/index.html',
      inject: true
    }),
    new HtmlWebpackPlugin({
      template: `${PAGES_DIR}/about/portfolio.html`,
      filename: './about/portfolio.html',
      inject: true
    }),

Vue install:

Default: already have

  1. Install vue
npm install vue --save
  1. Init vue index.js:
const app = new Vue({
  el: '#app'
})
  1. Create div id app
<div id="app">
  <!-- content -->
</div>

Vuex install:

  1. Install vuex
npm install vuex --save
  1. Import Vuex
import store from './store'
  1. Create index.js in ./store
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

export default new Vuex.Store({
  // vuex content
})

Add Vue Components:

Create your component in /components/

HTML Usage:

  1. Init component in index.js:
Vue.component('example-component', require('./components/Example.vue').default)
  1. Any html files:
 <example-component />

VUE Usage:

  1. import components in .vue:
import example from '~/components/Example.vue'
  1. Register component:
  components: {
    example
  }
  1. Init in vue component:
<example />

Add Fonts:

Сhoose one of the ways:

  1. Handle menthod,
  2. Use mixin;

Handle:

Add @font-face in /assets/scss/utils/fonts.scss:

// Example with Helvetica
@font-face {
  font-family: "Helvetica-Base";
  src: url('/assets/fonts/Helvetica/Base/Helvetica-Base.eot'); /* IE9 Compat Modes */
  src: url('/assets/fonts/Helvetica/Base/Helvetica-Base.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
       url('/assets/fonts/Helvetica/Base/Helvetica-Base.woff') format('woff'), /* Pretty Modern Browsers */
       url('/assets/fonts/Helvetica/Base/Helvetica-Base.ttf')  format('truetype'), /* Safari, Android, iOS */
       url('/assets/fonts/Helvetica/Base/Helvetica-Base.svg') format('svg'); /* Legacy iOS */
}

Add vars for font in /assets/scss/utils/vars.scss:

$mySecontFont : 'Helvetica-Base', Arial, sans-serif;

Or with mixin:

By default template support only modern format fonts: .woff, .woffs;

If ypu need svg or more formaths use another mixin in src/assets/scss/utils/mixin.scss

Usage:

  1. Put your font to src/assets/fonts/FOLDERNAME/FONTNAME. FOLLOW: Files Required: Example: .woff, .woffs formats;
  2. Go to fonts.scss;
  3. Use mixin Example: @include font-face("OpenSans", "../fonts/OpenSans/opensans");, Example 2: @include font-face("OpenSans", "../fonts/OpenSans/opensansItalic", 400, italic);.

License

MIT

Copyright (c) 2018-present, Evgenii Vedegis

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].