Giter Site home page Giter Site logo

wildpeaks / 2016-example-webpack2-es2015 Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 0.0 94 KB

[ARCHIVED] Sample project for ES2015 web development (including code coverage of ES Modules), using Webpack 2

License: MIT License

JavaScript 84.78% CSS 9.97% HTML 5.25%

2016-example-webpack2-es2015's Introduction

Webpack for ES2015

Sample project for ES2015 web development (including code coverage of ES Modules), using Webpack 2 beta.


/src/node_modules

Sources are located in folder /src, especially in /src/node_modules.

Note that the name "node_modules" doesn't imply "thirdparty from NPM", it's just how Node resolves paths (hence why NPM uses it).

That's why /src/application.js and modules in /src/node_modules subfolders are able to import other modules using clean paths like components/hello instead of fragile paths like ../../../components/hello/hardcoded.js without the need for aliasing folder hacks in every tool of your stack.


Webpack

Run npm start to launch the development server, then open http://localhost:8000/webpack-dev-server in your browser to see changes in realtime without the need to build manually or reload the webpage.

Alternatively, run npm run build to output files for production (in folder www).

You can change the Babel plugins and presets in /babel.config.js.


Javascript

The project is configured for ES2015 javascript (transpiled to ES5 using Babel 6), so you can use features like arrow functions, template strings, const, let, etc..

You can use both ES Modules (preferably) or CommonJS.

Flow type annotations are also supported.


CSS

CSS is postprocessed by PostCSS and CSSNext.

Autoprefixer is configured for IE11+.

CSS Modules

Webpack is configured to use Local Scope which generates globally-unique class names:

MyComponent.css:

.class1 {
	color: green;
}

MyComponent.js:

import styles from './MyComponent.css';
console.log(styles.class1);

To disable Local Scope, set modules: false in css loader query, in webpack.config.js.


Tests & Coverage

Mocha tests are located with the module they test, are named modulename.tests.js, and are run using npm test.

You can change the location of the tests in the root package.json settings (if you prefer a centralized test folder for example).


Coverage

The coverage report generated by Istanbul.js is outputted in /coverage, and is run using npm run coverage.

You can change the output folder and reporters in the root package.json settings.


Linting

You can run manually Eslint on the codebase using npm run lint, and Flow using npm run typecheck.

I'd also recommend integrating them to your favorite IDE, so you get immediate feedback from the linters. Sublime Text, for example, has Sublimelinter-contrib-eslint and Sublimelinter-flow extensions.


2016-example-webpack2-es2015's People

Contributors

cecilemuller avatar

Stargazers

Terkel avatar Alan Fernandez avatar Aaron Harvey avatar Jonathan Amsellem avatar Aaron LEE K.S. avatar  avatar Arttu Hanska avatar  avatar Denis Denisov avatar Chris Watson avatar Johan Borestad avatar Chia-liang Kao avatar  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.