Skip to content

Commit

Permalink
Fix pre-commit config, format tooling files
Browse files Browse the repository at this point in the history
  • Loading branch information
faultyserver committed Oct 29, 2019
1 parent de4abb8 commit 12823f0
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
entry: ./node_modules/.bin/prettier
language: node
stages: [commit]
files: ^(static/)*.(js|css)
files: (.*)\.(js|css)$
args: ["--write"]
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
static/
File renamed without changes.
16 changes: 4 additions & 12 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
const sharedConfig = require('./shared.webpack')({context: {DEBUG: true}});
const sharedConfig = require('./shared.webpack')({ context: { DEBUG: true } });
const webpackConfig = require('./webpack.config.js');
process.env.CHROME_BIN = require('puppeteer').executablePath();
module.exports = function (config) {
module.exports = function(config) {
config.set({
autoWatch: true,
browsers: ['ChromeHeadless'],
frameworks: ['jasmine'],
files: [
'bundles/init/index.js',
'bundles/**/*_spec.js',
'bundles/**/*Spec.js',
],
files: ['bundles/init/index.js', 'bundles/**/*_spec.js', 'bundles/**/*Spec.js'],
preprocessors: {
'bundles/init/*.js': ['webpack'],
'bundles/**/*_spec.js': ['webpack'],
Expand All @@ -26,10 +22,6 @@ module.exports = function (config) {
noInfo: true,
poll: 1000,
},
plugins: [
require('karma-webpack'),
require('karma-jasmine'),
require('karma-chrome-launcher'),
],
plugins: [require('karma-webpack'), require('karma-jasmine'), require('karma-chrome-launcher')],
});
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"build": "git clean -fxd static && cross-env NODE_ENV=production webpack",
"start": "cross-env NODE_ENV=${NODE_ENV:-development} SOURCE_MAPS=${SOURCE_MAPS:-1} webpack-dev-server",
"test": "karma start --single-run",
"test:watch": "karma start"
"test:watch": "karma start",
"fix:prettier": "prettier --write \"bundles/**\""
},
"author": "",
"license": "ISC",
Expand Down
52 changes: 16 additions & 36 deletions shared.webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,21 @@ const _ = require('lodash');
const packageJSON = require('./package.json');

function keyMirror(obj) {
return Object.keys(obj).reduce(function (memo, key) {
return Object.keys(obj).reduce(function(memo, key) {
memo[key] = key;
return memo;
}, {});
}


module.exports = function (opts = {}) {
module.exports = function(opts = {}) {
const hmr = opts.hmr || process.env.NODE_ENV === 'development';
return {
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
use: _.compact([
hmr && 'react-hot-loader/webpack',
'babel-loader',
]),
use: _.compact([hmr && 'react-hot-loader/webpack', 'babel-loader']),
},
{
test: /\.css$/,
Expand All @@ -43,31 +39,25 @@ module.exports = function (opts = {}) {
localIdentName: '[local]--[hash:base64:10]',
},
},
}
},
],
},
{
test: /\.(png|jpg|svg)$/,
use: [
'url-loader',
],
use: ['url-loader'],
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [
'url-loader?limit=10000&mimetype=application/font-woff'
],
use: ['url-loader?limit=10000&mimetype=application/font-woff'],
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [
'file-loader',
],
}
use: ['file-loader'],
},
],
},
node: {
fs: 'empty'
fs: 'empty',
},
resolve: {
alias: {
Expand All @@ -77,24 +67,14 @@ module.exports = function (opts = {}) {
poll: 1000,
externals: keyMirror(packageJSON.dependencies),
devServer: {
proxy: [{
context: [
'/admin',
'/logout',
'/api',
'/ui',
'/static',
'/tracker',
'/donate',
],
target: 'http://localhost:8000/',
headers: {'X-Webpack': 1},
}],
allowedHosts: [
'localhost',
'127.0.0.1',
'.ngrok.io',
proxy: [
{
context: ['/admin', '/logout', '/api', '/ui', '/static', '/tracker', '/donate'],
target: 'http://localhost:8000/',
headers: { 'X-Webpack': 1 },
},
],
allowedHosts: ['localhost', '127.0.0.1', '.ngrok.io'],
},
};
};
11 changes: 5 additions & 6 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const WebpackManifestPlugin = require('webpack-yam-plugin');
const sharedConfig = require('./shared.webpack')();


const PROD = process.env.NODE_ENV === 'production';

console.log(PROD ? 'PRODUCTION BUILD' : 'DEVELOPMENT BUILD');
Expand All @@ -16,17 +15,17 @@ module.exports = {
donate: ['./bundles/init', './bundles/donate'],
},
output: {
'filename': PROD ? 'tracker-[name]-[hash].js' : 'tracker-[name].js',
'pathinfo': true,
'path': __dirname + '/static/gen',
'publicPath': '/static/gen',
filename: PROD ? 'tracker-[name]-[hash].js' : 'tracker-[name].js',
pathinfo: true,
path: __dirname + '/static/gen',
publicPath: '/static/gen',
},
module: sharedConfig.module,
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new WebpackManifestPlugin({
manifestPath: __dirname + '/ui-tracker.manifest.json',
outputRoot: __dirname + '/static'
outputRoot: __dirname + '/static',
}),
new MiniCssExtractPlugin({
filename: PROD ? 'tracker-[name]-[hash].css' : 'tracker-[name].css',
Expand Down

0 comments on commit 12823f0

Please sign in to comment.