GithubHelp home page GithubHelp logo

webpack-setup's Introduction

Webpack Installation [personal setup, ongoing, non-componentized]

Introduction

This setup sidesteps the usual webpack default setup and instead outputs css and js into one file each (like gulp). It is meant to be used for projects that aren't javascript heavy or aren't set up to be fully made of components, or if you just want to practice some webpack stuff.

Init

npm install

For full list of packages, see package.json in root.

Webpack

This project is compiled using webpack. Configuration is in webpack.config.js in the root.

Available command line options:

webpack or npm run dev - default command. runs babel, js bundler and sass compiler.

npm run watch - runs the above and watches for changes.

npm run build - for production. runs babel, js bundler, js uglify, sass compiler, and sass minification.

(see scripts in package.json for details)

Folder structure

root
|-- ProjectFolder
|   |-- build 
|   |   |-- scripts.js //compiled js
|   |   `-- style.css //compiled css
|   |-- src
|   |   |-- js
|   |   |   |-- components
|   |   |   |   |-- component1.js
|   |   |   |   |-- component2.js
|   |   |   |   `-- etc.
|   |   |   `--scripts.js //js entry point
|   |   |-- sass
|   |   |   |-- partials
|   |   |   |   |-- _variables.scss
|   |   |   |   |-- _globals.scss
|   |   |   |   `-- etc.
|   |   |   `--style.scss //css/sass entry point

Notes

  • node-sass (in the form of loader sass-loader) is run on dev as it is fairly quick.
  • PostCSS (postcss-loader) is run on production builds. it is slower but has more compression options.

CHANGELOG Sept 18/17

  • rename rules to loaders to match common syntax moving forward by webpack
  • remove -d and -p flags from package.json scripts to denote builds, use process.env.NODE_ENV instead note installation of cross-env in npm required
  • add sourcemaps to dev build
  • add jshint to dev build
  • add devtool method to global config for sourcemaps in browser
  • fix postcss for prod builds (now includes autoprefixer)
  • clean up package.json

TODO

  • JS linter
  • Tree shaking
  • commonschunkplugin
  • image minification
  • SVG minification & spritesheets
  • FED performance testing

webpack-setup's People

Contributors

kerelist avatar

Watchers

James Cloos avatar  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.