Build set-up based on webpack and npm scripts for common needs.
- dividing source code from compiled
- separated production task
- modularity
- modern, future-proof technologies
- linting (code style / syntax errors checking)
- browsers live reloading
- dependencies through node modules (you can install libraries through NPM and import them in your styles/scripts)
- Webpack 3.x
- Normalize.css
- PostCSS: CSSNext OR Sass + autoprefixer
- Sourcemaps
Note You can choose only PostCSS or Sass (default is Sass):
- change
STYLES
variable in package.json - remove unecessary folder (/src/postcss or /src/scss).
- change styles file include in src/app.js
- Javascript: ES2015+ (Babel env config)
- Sourcemaps
- (Styles) Stylelint: standard config (+
stylelint-scss
for Sass) + some sensible settings - (Scripts) ESLint: recommended config (+ optional: Airbnb config)
- sprites generator (spritesmith)
- imagemin
- BrowserSync
- Webpack dev server
src/
- app.js - main project file where all other files are included
- main source file (main.css / main.scss)
- base/:
- elements: base html elements styles
- objects/: OOCSS
- layout/: layouts
- components/: BEM, Atomic Design
- settings/: project setup (variables, etc)
- utilities/: mixins
- main source file (main.js)
- modules/: folder for javascript modules
- img/ - source images
- img/sprite/ - source images for sprite
dist/
- css/main.css - output css
- js/main.js - output js
- assets/ - output files which relate to build (images, fonts, etc)
- Node.js - latest v6.x LTS "Boron" is recommended
npm install
npm run build
- build projectnpm run start
- build and watch changes (with BrowserSync)npm run start:webpack-server
- build and watch changes (with Webpack dev server)npm run build:prod
- build production-ready code
Also, you can see subtasks in package.json
.
You should remove HTML processing:
- delete src/pug folder
- remove HtmlWebpackPlugin from webpack.config.babel.js config
new HtmlWebpackPlugin({
template: 'pug/index.pug'
}),
And set up BrowserSync:
- remove
server
option from BrowserSyncPlugin in webpack.config.babel.js - add
proxy
option with you local development environment address
new BrowserSyncPlugin({
files: "dist/**/*.*",
hostname: "localhost",
port: 8080,
proxy: "local.dev",
reloadDelay: 50,
injectChanges: false,
reloadDebounce: 500,
reloadOnRestart: true
}),
- > 0.5%
- last 2 versions
- IE11+
- nvm, Node.js, NPM, Yarn
- Webpack
- Webpack dev server
- CSS: Normalize.css, OOCSS, BEM, Atomic Design
- PostCSS: CSSNext
- Sass (SCSS)
- Sourcemaps
- JavaScript: ES2015, ES2016, JavaScript Modules
- Module Bundling
- Linters: Stylelint, ESLint
- Images: spritesmith, imagemin
- png icon examples (for sprite) designed by Vectors Market from Flaticon (http://www.flaticon.com/packs/business-and-finance-11)