├── .babelrc
├── .editorconfig
├── .eslintrc
├── .gitignore
├── .travis.yml
├── LICENSE
├── demo
├── app.js
└── index.tpl.html
├── dist
├── .keep
├── index.js
└── styles.css
├── index.js
├── karma.conf.js
├── lib
├── .keep
└── index.js
├── package.json
├── readme.md
├── src
├── index.js
└── styles.scss
├── test
├── .keep
├── example
│ └── calc.js
└── index.js
├── tmp
├── .keep
├── Astronaut.svg
└── oskit.png
├── webpack.config.dist.js
├── webpack.config.js
└── webpack.karma.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015", "stage-0"],
3 | }
4 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 4
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 |
12 | [package.json]
13 | indent_style = space
14 | indent_size = 2
15 |
16 | [*.md]
17 | trim_trailing_whitespace = false
18 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "parser": "babel-eslint",
4 | "rules": {
5 | "strict": [2, "global"],
6 | "no-debugger": 2,
7 | "no-extra-semi": 2,
8 | "no-constant-condition": 2,
9 | "no-extra-parens": [2, "functions"],
10 | "no-func-assign": 2,
11 | "no-obj-calls": 2,
12 | "no-unexpected-multiline": 2,
13 | "no-unreachable": 2,
14 | "use-isnan": 2,
15 | "no-extend-native": [2, {"exceptions": ["Object"]}],
16 | "no-alert": 2,
17 | "no-caller": 1,
18 | "no-eval": 2,
19 | "no-dupe-keys": 2,
20 | "no-empty-pattern": 2,
21 | "no-delete-var": 2,
22 | "no-undef-init": 2,
23 | "no-undef": 2,
24 | "no-unused-vars": [2, {"vars": "all", "args": "none", "varsIgnorePattern": "^_|$"}],
25 | "comma-dangle" : [2, "never"]
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # Compiled binary addons (http://nodejs.org/api/addons.html)
20 | build/Release
21 |
22 | # Dependency directory
23 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
24 | node_modules
25 |
26 | # Debug log from npm
27 | npm-debug.log
28 |
29 | # IDEA
30 | .idea
31 |
32 | # Assets
33 | assets.json
34 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 |
3 | node_js:
4 | - "5"
5 |
6 | sudo: false
7 |
8 | addons:
9 | code_climate:
10 | repo_token: ed7affb886ea3697ade7b50bc36a3be66af736fc01c4e2526d3fd819c5051630
11 |
12 | cache:
13 | directories:
14 | - "travis-phantomjs"
15 |
16 | before_install:
17 | - "[ -d travis-phantomjs ] || mkdir travis-phantomjs && PHANTOM_EXISTS=false"
18 | - "if [ $PHANTOM_EXISTS = 'false' ]; then wget https://assets.membergetmember.co/software/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2; fi"
19 | - "if [ $PHANTOM_EXISTS = 'false' ]; then tar -xvf $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis-phantomjs; fi"
20 | - "export PATH=$PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH"
21 | - "phantomjs --version"
22 |
23 | before_script:
24 | - npm install -g codeclimate-test-reporter
25 | script:
26 | - npm test
27 |
28 | after_script:
29 | - codeclimate-test-reporter < dist/coverage/**/lcov.info
30 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Dmitry Poddubniy
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/demo/app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import Calc from '../src';
4 |
5 | let calc = new Calc(0);
6 |
7 | console.log(calc.add(2).memory());
8 | console.log(calc.reset().add(5).memory());
9 |
--------------------------------------------------------------------------------
/demo/index.tpl.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/dist/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mr47/opensource-kit/cbc3ecdd6a82229217dab4cfecc46972b65f1dff/dist/.keep
--------------------------------------------------------------------------------
/dist/index.js:
--------------------------------------------------------------------------------
1 | !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t["default"]=e,t}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;r=5.0.0"
26 | },
27 | "devDependencies": {
28 | "autoprefixer": "^6.3.1",
29 | "babel-cli": "^6.5.1",
30 | "babel-core": "^6.5.1",
31 | "babel-eslint": "^6.0.0-beta.6",
32 | "babel-loader": "^6.2.2",
33 | "babel-plugin-react-transform": "^2.0.0",
34 | "babel-polyfill": "^6.5.0",
35 | "babel-preset-es2015": "^6.5.0",
36 | "babel-preset-stage-0": "^6.5.0",
37 | "babel-runtime": "^6.5.0",
38 | "browser-sync": "^2.11.1",
39 | "browser-sync-webpack-plugin": "^1.0.1",
40 | "chai": "^3.5.0",
41 | "css-loader": "^0.23.1",
42 | "extract-text-webpack-plugin": "^1.0.1",
43 | "html-webpack-plugin": "^2.10.0",
44 | "isparta": "^4.0.0",
45 | "isparta-loader": "^2.0.0",
46 | "karma": "^0.13.22",
47 | "karma-chai": "^0.1.0",
48 | "karma-coverage": "^0.5.5",
49 | "karma-eslint": "^2.1.0",
50 | "karma-mocha": "^0.2.2",
51 | "karma-mocha-reporter": "^2.0.0",
52 | "karma-phantomjs-launcher": "^1.0.0",
53 | "karma-spec-reporter": "0.0.24",
54 | "karma-webpack": "^1.7.0",
55 | "mocha": "^2.4.5",
56 | "node-sass": "^3.4.2",
57 | "phantomjs-polyfill": "0.0.2",
58 | "phantomjs-prebuilt": "^2.1.6",
59 | "postcss-loader": "^0.8.0",
60 | "progress-bar-webpack-plugin": "^1.3.0",
61 | "sass-loader": "^3.1.2",
62 | "style-loader": "^0.13.0",
63 | "webpack": "^1.12.13",
64 | "webpack-dev-server": "^1.14.1"
65 | },
66 | "author": "mr47",
67 | "license": "MIT",
68 | "bugs": {
69 | "url": "https://github.com/mr47/opensource-kit/issues"
70 | },
71 | "homepage": "https://github.com/mr47/opensource-kit#readme",
72 | "dependencies": {
73 | "bluebird": "^3.3.4",
74 | "jquery": "^2.2.1",
75 | "lodash": "^4.6.1"
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | []()
2 | []()
3 | []()
4 | [](https://codeclimate.com/github/mr47/opensource-kit)
5 | [](https://codeclimate.com/github/mr47/opensource-kit/coverage)
6 | [](https://twitter.com/seekmode)
7 |
8 |
9 |
10 |
11 |
12 | > Open source kit for people who writes a nice code.
13 |
14 | Create simple, flexible libraries without worry about production ready covered code. Simple and easy to use.
15 |
16 | Do you wanna build you library with few lines of `npm` ?.
17 |
18 | No need to find `amazing-new-boilerplate-with-black-jack` just use `Open source kit`.
19 |
20 | You create a lib and just run `npm run build` thats all. Its clean minified uglified code with coverage.
21 |
22 | [Wanna help?](#contributing)
23 |
24 | ##Installation
25 | ```bash
26 | $ git clone https://github.com/mr47/opensource-kit
27 | ```
28 | bad idea but still available :
29 | ```bash
30 | $ npm install opensource-kit
31 | ```
32 | ##Whats inside:
33 |
34 | - [Webpack](https://webpack.github.io/) (bundler, with demo external lib)
35 | - [Babel](https://babeljs.io) ( stage 0, es2015 )
36 | - [Karma](https://karma-runner.github.io) (Runner for tests)
37 | - [Mocha](https://mochajsorg/) (tests framework)
38 | - [Chai](http://chaijs.com/)
39 | - [Isparta](https://github.com/douglasduteil/isparta) (coverage, es2015 source quality!)
40 | - Sass (scss)
41 | - [ESLint](https://github.com/eslint/eslint)
42 |
43 | ###Additional:
44 |
45 | - [.editorconfig](http://editorconfig.org/)
46 | - [.babelrc](https://babeljs.io/docs/usage/babelrc/)
47 |
48 | ###Demo:
49 |
50 | - [Webpack Dev Server](https://webpack.github.io/docs/webpack-dev-server.html)
51 | - [Browser sync](https://www.browsersync.io/)
52 |
53 | ##Publishing you package
54 | To follow [semver](http://semver.org/) use follow commands (before update version in `package.json` it runs `npm run preversion`)
55 |
56 | To make a patch:
57 | ```bash
58 | $ npm version patch
59 | ```
60 | To make a minor change:
61 | ```bash
62 | $ npm version minor
63 | ```
64 | To make a major change:
65 | ```bash
66 | $ npm version major
67 | ```
68 |
69 | To publish package to npm:
70 | ```bash
71 | $ npm publish
72 | ```
73 |
74 | ##Build
75 | Complete build to `./dist/`
76 | ```bash
77 | $ npm run build
78 | ```
79 | Babel build `./lib/`
80 | ```bash
81 | $ npm run build:babel
82 | ```
83 | Webpack build
84 | ```bash
85 | $ npm run build:webpack
86 | ```
87 |
88 | ##Test
89 | It will run karma with config `karma.conf.js`
90 | ```bash
91 | $ npm test
92 | ```
93 | ##Run Demo
94 | ```bash
95 | $ npm run start
96 | ```
97 |
98 | ##Motivation
99 | I writed few big/small/zero projects last months, and tested my env. For many reasons i choose some components one by another so for now its my stack for javascript code.
100 |
101 | ##TODO
102 |
103 | See issues.
104 |
105 | ##Node and npm version tested
106 | []()
107 | []()
108 |
109 | #CONTRIBUTING
110 | Pull request are welcome, just fork repo.
111 |
112 | ## Installation
113 |
114 | Install dependencies using `npm install`.
115 |
116 | ## Building
117 |
118 | Build the source code using `npm run build`.
119 |
120 | ##License
121 | MIT
122 |
123 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by mr470 on 10.03.2016.
3 | */
4 | import * as styles from './styles.scss';
5 |
6 | class Calc{
7 | register = 0;
8 | innerHistory = [];
9 | constructor(initValue = 0){
10 | this.register = initValue;
11 | return this;
12 | }
13 | add(value = 0){
14 | this.innerHistory.push([value, this.register]);
15 | this.register = this.register + value;
16 | return this;
17 | }
18 | reset(value = 0){
19 | this.register = value || 0;
20 | return this;
21 | }
22 | memory(value){
23 | if (value) {
24 | this.reset(value);
25 | this.innerHistory = [];
26 | return this;
27 | } else {
28 | return this.register;
29 | }
30 | }
31 | history(value){
32 | if (value) {
33 | this.innerHistory = [value];
34 | return this;
35 | } else {
36 | return this.innerHistory;
37 | }
38 | }
39 | }
40 |
41 | export default Calc;
42 |
--------------------------------------------------------------------------------
/src/styles.scss:
--------------------------------------------------------------------------------
1 | .test{
2 | color: red;
3 | }
4 |
--------------------------------------------------------------------------------
/test/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mr47/opensource-kit/cbc3ecdd6a82229217dab4cfecc46972b65f1dff/test/.keep
--------------------------------------------------------------------------------
/test/example/calc.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | import 'chai';
4 |
5 | import Calc from './../../src/index';
6 |
7 | describe("Calculator", ()=>{
8 |
9 | it("shoud get init value - zero", ()=>{
10 | let calc = new Calc(0);
11 | const mem = calc.memory();
12 | mem.should.be.a('Number');
13 | mem.should.equal(0);
14 | });
15 |
16 | it("should return a register", ()=>{
17 | let calc = new Calc(10);
18 | let mem = calc.memory();
19 | mem.should.be.a('Number');
20 | mem.should.equal(10);
21 | });
22 |
23 | it("should setup a register", ()=>{
24 | let calc = new Calc(0);
25 | let mem = calc.memory(9).memory();
26 | mem.should.be.a('Number');
27 | mem.should.equal(9);
28 | });
29 |
30 | it("should add 2 to register", ()=>{
31 | let calc = new Calc(0);
32 | let mem = calc.add(2).memory();
33 | mem.should.be.a('Number');
34 | mem.should.equal(2);
35 | });
36 |
37 | it("should reset a register", ()=>{
38 | let calc = new Calc(0);
39 | let mem = calc.add(2).reset().memory();
40 |
41 | mem.should.be.a('Number');
42 | mem.should.equal(0);
43 | });
44 |
45 | it("should remember a history with results", ()=>{
46 | let calc = new Calc(0);
47 | let mem = calc
48 | .add(2)
49 | .add(3)
50 | .memory();
51 | let history = calc.history();
52 | expect(history).to.deep.equal([[2, 0], [3, 2]]);
53 | mem.should.be.a('Number');
54 | mem.should.equal(5);
55 | });
56 |
57 | it("should setup a history", ()=>{
58 | let calc = new Calc(0);
59 | let mem = calc
60 | .add(2)
61 | .add(3)
62 | .memory();
63 | calc.history([-1,-1]);
64 | let history = calc.history();
65 | expect(history).to.deep.equal([[-1,-1]]);
66 | mem.should.be.a('Number');
67 | mem.should.equal(5);
68 | });
69 |
70 | it("should remember a history with results", ()=>{
71 | let calc = new Calc(0);
72 | let mem = calc
73 | .add(2)
74 | .add(3)
75 | .memory();
76 | let history = calc.history();
77 | expect(history).to.deep.equal([[2, 0], [3, 2]]);
78 | mem.should.be.a('Number');
79 | mem.should.equal(5);
80 | });
81 |
82 | });
83 |
--------------------------------------------------------------------------------
/test/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by mr470 on 20.03.2016.
3 | */
4 |
5 | import './example/calc';
6 |
--------------------------------------------------------------------------------
/tmp/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mr47/opensource-kit/cbc3ecdd6a82229217dab4cfecc46972b65f1dff/tmp/.keep
--------------------------------------------------------------------------------
/tmp/Astronaut.svg:
--------------------------------------------------------------------------------
1 |
2 |
26 |
--------------------------------------------------------------------------------
/tmp/oskit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mr47/opensource-kit/cbc3ecdd6a82229217dab4cfecc46972b65f1dff/tmp/oskit.png
--------------------------------------------------------------------------------
/webpack.config.dist.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var path = require('path');
3 | var webpack = require('webpack');
4 | var ExtractTextPlugin = require('extract-text-webpack-plugin');
5 | var progressBarPlugin = require('progress-bar-webpack-plugin');
6 | var autoprefixer = require('autoprefixer');
7 |
8 | var cssLoaders = [
9 | "css?sourceMap&modules&localIdentName=[name]---[local]---[hash:base64:5]",
10 | "postcss",
11 | "sass?sourceMap"
12 | ];
13 |
14 | module.exports = {
15 | entry: {
16 | index: ["./src/index"]
17 | },
18 | output: {
19 | path: path.join(__dirname, "dist"),
20 | filename: "[name].js",
21 | libraryTarget: "umd"
22 | },
23 | plugins: [
24 | new webpack.optimize.OccurenceOrderPlugin(),
25 | new progressBarPlugin(),
26 | new webpack.DefinePlugin({
27 | 'process.env.NODE_ENV': JSON.stringify('production'),
28 | 'NODE_ENV': JSON.stringify('production')
29 | }),
30 | new webpack.ProvidePlugin({
31 | $: "jquery",
32 | jQuery: "jquery",
33 | "_": "lodash",
34 | Promise: "bluebird"
35 | }),
36 | new ExtractTextPlugin("styles.css", {
37 | allChunks: true
38 | }),
39 | new webpack.optimize.UglifyJsPlugin({
40 | compress: {
41 | warnings: false,
42 | drop_console: true
43 | }
44 | }),
45 | new webpack.NoErrorsPlugin()
46 | ],
47 | resolve: {
48 | extensions: ['', '.js', '.scss'],
49 | modulesDirectories: ["node_modules", "src"]
50 | },
51 | module: {
52 | loaders: [
53 | {
54 | test: /\.js?$/,
55 | exclude: /node_modules/,
56 | loader: 'babel'
57 | },
58 | {
59 | test: /\.scss/,
60 | loader: ExtractTextPlugin.extract("style-loader", cssLoaders.join("!"))
61 | }
62 | ]
63 | },
64 | externals: [
65 | {
66 | "lodash": {
67 | root: "_",
68 | commonjs2: "lodash",
69 | commonjs: "lodash",
70 | amd: "lodash"
71 | },
72 | "jquery": {
73 | root: "jQuery",
74 | commonjs2: "jquery",
75 | commonjs: "jquery",
76 | amd: "jquery"
77 | },
78 | "bluebird": {
79 | root: "bluebird",
80 | commonjs2: "bluebird",
81 | commonjs: "bluebird",
82 | amd: "bluebird"
83 | }
84 | }
85 | ],
86 | postcss: [ autoprefixer({ browsers: ['last 2 versions'] }) ]
87 | };
88 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var webpack = require('webpack');
4 | var path = require('path');
5 | var autoprefixer = require('autoprefixer');
6 | var HtmlWebpackPlugin = require('html-webpack-plugin');
7 | var BrowserSyncPlugin = require('browser-sync-webpack-plugin');
8 |
9 | var cssLoaders = [
10 | "style",
11 | "css?sourceMap&modules&localIdentName=[name]---[local]---[hash:base64:5]",
12 | "postcss",
13 | "sass?sourceMap"
14 | ];
15 |
16 | module.exports = {
17 |
18 | output: {
19 | path: path.resolve(__dirname, "tmp"),
20 | filename: 'index.js',
21 | publicPath: '/'
22 | },
23 |
24 | cache: true,
25 | debug: false,
26 | devtool: false,
27 | entry: [
28 | './demo/app.js'
29 | ],
30 |
31 | stats: {
32 | colors: true,
33 | reasons: true
34 | },
35 |
36 | resolve: {
37 | extensions: ['', '.js', '.scss'],
38 | modulesDirectories: ["node_modules", "../src"]
39 | },
40 | module: {
41 | loaders: [
42 | {
43 | test: /\.js$/,
44 | exclude: [/node_modules/],
45 | loader: 'babel-loader'
46 | },
47 | {
48 | test: /\.scss/,
49 | loader: cssLoaders.join("!")
50 | },
51 | {
52 | test: /\.(png|jpg)$/,
53 | loader: 'url-loader?limit=8192'
54 | }
55 | ]
56 | },
57 | postcss: [ autoprefixer({ browsers: ['last 2 versions'] }) ],
58 | plugins: [
59 | new webpack.HotModuleReplacementPlugin(),
60 | new webpack.ProvidePlugin({
61 | $: "jquery",
62 | jQuery: "jquery",
63 | "_": "lodash",
64 | Promise: "bluebird"
65 | }),
66 | new HtmlWebpackPlugin({
67 | template: path.resolve('demo', 'index.tpl.html'),
68 | inject: 'body',
69 | filename: 'index.html'
70 | }),
71 | new BrowserSyncPlugin({
72 | // browse to http://localhost:3000/ during development
73 | host: 'localhost',
74 | port: 3000,
75 | // proxy the Webpack Dev Server endpoint
76 | // (which should be serving on http://localhost:3100/)
77 | // through BrowserSync
78 | proxy: 'http://localhost:8080/'
79 | },
80 | // plugin options
81 | {
82 | // prevent BrowserSync from reloading the page
83 | // and let Webpack Dev Server take care of this
84 | reload: false
85 | }),
86 | new webpack.NoErrorsPlugin()
87 | ]
88 |
89 | };
90 |
--------------------------------------------------------------------------------
/webpack.karma.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by mr470 on 20.03.2016.
3 | */
4 |
5 | "use strict";
6 |
7 | var path = require('path');
8 | var webpack = require('webpack');
9 | var autoprefixer = require('autoprefixer');
10 |
11 | var cssLoaders = [
12 | "style",
13 | "css?sourceMap&modules&localIdentName=[name]---[local]---[hash:base64:5]",
14 | "postcss",
15 | "sass?sourceMap"
16 | ];
17 |
18 | module.exports = {
19 | resolve: {
20 | extensions: ['', '.js', '.scss'],
21 | modulesDirectories: ["node_modules", "src"]
22 | },
23 | module: {
24 | loaders: [
25 | {
26 | test: /\.js?$/,
27 | exclude: /node_modules/,
28 | loader: 'babel'
29 | },
30 | {
31 | test: /\.scss/,
32 | loader: cssLoaders.join("!")
33 | }
34 | ],
35 | preLoaders: [
36 | // transpile all files except testing sources with babel as usual
37 | {
38 | test: /\.js$/,
39 | exclude: [
40 | path.resolve('src/components/'),
41 | path.resolve('node_modules/')
42 | ],
43 | loader: 'babel'
44 | },
45 | // transpile and instrument only testing sources with isparta
46 | {
47 | test: /\.js$/,
48 | include: path.resolve('src/'),
49 | loader: 'isparta'
50 | }
51 | ]
52 | },
53 |
54 | postcss: [ autoprefixer({ browsers: ['last 2 versions'] }) ]
55 | };
56 |
--------------------------------------------------------------------------------