Last active
August 25, 2016 16:48
-
-
Save Calamari/5badf16d135754d0842ee9eed4948514 to your computer and use it in GitHub Desktop.
Webpack, Karma, jasmine, react Boilerplate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": ["es2015", "react"], | |
"plugins": [ | |
"add-module-exports", | |
"transform-object-rest-spread", | |
"transform-class-properties", | |
"transform-flow-strip-types" | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable */ | |
module.exports = { | |
"extends": "airbnb", | |
// used for flowtype | |
"parser": "babel-eslint", | |
"parserOptions": { | |
"ignorePattern": ".eslintrc.js", | |
"ecmaFeatures": { | |
"experimentalObjectRestSpread": true | |
} | |
}, | |
"globals": {}, | |
"rules": { | |
"comma-dangle": 0, | |
"no-underscore-dangle": 0, | |
"max-len": [0, 140], | |
// Fires on none react files as well, where we not need it | |
"react/jsx-no-bind": 0 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ignore] | |
.*/node_modules/.* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install --save-dev webpack babel-loader babel-core babel-preset-es2015 babel-plugin-transform-runtime babel-plugin-transform-object-rest-spread react babel-preset-react babel-polyfill | |
# Install js testing using Karma | |
npm install --save-dev karma-babel-preprocessor karma-webpack karma-jasmine karma-chrome-launcher karma karma-cli babel-istanbul babel-istanbul-loader fstream-ignore karma-coverage karma-webpack karma-sourcemap-loader jasmine babel-plugin-add-module-exports deep-freeze | |
# When using flow type checking: | |
npm install --save-dev flow-bin babel-plugin-transform-flow-strip-types eslint-plugin-flowtype babel-plugin-transform-class-properties | |
# Installing react and redux | |
npm install --save-dev react-dom react-redux redux | |
# If we want to have eslinting | |
npm install --save-dev eslint babel-eslint eslint-config-airbnb eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react | |
# Create js app source and test dirs | |
mkdir -p js_app/__tests__ | |
# Create js output dir | |
mkdir -p public/a/ | |
# Create starting file | |
touch js_app/index.js | |
# Create according test file | |
touch js_app/__tests__/index-test.js | |
# Config file for flow | |
touch .flowconfig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'); | |
module.exports = function (config) { | |
config.set({ | |
browsers: ['Chrome'], | |
coverageReporter: { | |
reporters: [ | |
{ type: 'html', subdir: 'html' }, | |
{ type: 'lcovonly', subdir: '.' }, | |
], | |
}, | |
files: [ | |
'tests.webpack.js', | |
], | |
frameworks: [ | |
'jasmine', | |
], | |
preprocessors: { | |
'tests.webpack.js': ['webpack', 'sourcemap'], | |
}, | |
reporters: ['progress', 'coverage'], | |
webpack: { | |
cache: true, | |
devtool: 'inline-source-map', | |
module: { | |
preLoaders: [ | |
{ | |
test: /-test\.js$/, | |
include: /js_app/, | |
exclude: /(bower_components|node_modules)/, | |
loader: 'babel', | |
query: { | |
cacheDirectory: true, | |
}, | |
}, | |
{ | |
test: /\.js?$/, | |
include: /js_app/, | |
exclude: /(node_modules|bower_components|__tests__)/, | |
loader: 'babel-istanbul', | |
query: { | |
cacheDirectory: true, | |
}, | |
}, | |
], | |
loaders: [ | |
{ | |
test: /\.js$/, | |
include: path.resolve(__dirname, '../js_app'), | |
exclude: /(bower_components|node_modules|__tests__)/, | |
loader: 'babel', | |
query: { | |
cacheDirectory: true, | |
}, | |
}, | |
], | |
}, | |
}, | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"flow": "flow; test $? -eq 0 -o $? -eq 2", | |
"test": "./node_modules/karma/bin/karma start karma.config.js" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var testsContext = require.context('./js_app', true, /-test\.js$/); | |
testsContext.keys().forEach(testsContext); | |
var srcContext = require.context('./js_app', true, /^((?!__tests__).)*.js$/); | |
srcContext.keys().forEach(srcContext); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
entry: [ | |
'babel-polyfill', | |
'./js_app/' | |
], | |
output: { | |
path: 'public/a/', | |
filename: 'app.js', | |
}, | |
resolve: { | |
extensions: ['', '.js', '.jsx'] | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.jsx?/, | |
loader: 'babel', | |
include: __dirname + '/js_app', | |
query: { | |
cacheDirectory: true | |
}, | |
} | |
] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment