client: replace deprecated vue-resource with axios, lint more file

This commit is contained in:
Matteo Pagliazzi
2017-01-15 20:49:15 +01:00
parent caa546eb62
commit bbffa9830b
21 changed files with 189 additions and 181 deletions

View File

@@ -1,22 +1,24 @@
var path = require('path');
var express = require('express');
var webpack = require('webpack');
var config = require('./config');
var proxyMiddleware = require('http-proxy-middleware');
var webpackConfig = process.env.NODE_ENV === 'testing'
? require('./webpack.prod.conf')
: require('./webpack.dev.conf');
/* eslint-disable no-process-env, no-console */
const path = require('path');
const express = require('express');
const webpack = require('webpack');
const config = require('./config');
const proxyMiddleware = require('http-proxy-middleware');
const webpackConfig = process.env.NODE_ENV === 'testing' ?
require('./webpack.prod.conf') :
require('./webpack.dev.conf');
// default port where dev server listens for incoming traffic
var port = process.env.PORT || config.dev.port;
const port = process.env.PORT || config.dev.port;
// Define HTTP proxies to your custom API backend
// https://github.com/chimurai/http-proxy-middleware
var proxyTable = config.dev.proxyTable;
const proxyTable = config.dev.proxyTable;
var app = express();
var compiler = webpack(webpackConfig);
const app = express();
const compiler = webpack(webpackConfig);
var devMiddleware = require('webpack-dev-middleware')(compiler, {
const devMiddleware = require('webpack-dev-middleware')(compiler, {
publicPath: webpackConfig.output.publicPath,
stats: {
colors: true,
@@ -24,18 +26,18 @@ var devMiddleware = require('webpack-dev-middleware')(compiler, {
},
});
var hotMiddleware = require('webpack-hot-middleware')(compiler);
const hotMiddleware = require('webpack-hot-middleware')(compiler);
// force page reload when html-webpack-plugin template changes
compiler.plugin('compilation', function (compilation) {
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
compiler.plugin('compilation', (compilation) => {
compilation.plugin('html-webpack-plugin-after-emit', (data, cb) => {
hotMiddleware.publish({ action: 'reload' });
cb();
});
});
// proxy api requests
Object.keys(proxyTable).forEach(function (context) {
var options = proxyTable[context];
Object.keys(proxyTable).forEach((context) => {
let options = proxyTable[context];
if (typeof options === 'string') {
options = { target: options };
}
@@ -53,13 +55,13 @@ app.use(devMiddleware);
app.use(hotMiddleware);
// serve pure static assets
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory);
const staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory);
app.use(staticPath, express.static(config.dev.staticAssetsDirectory));
module.exports = app.listen(port, function (err) {
module.exports = app.listen(port, (err) => {
if (err) {
console.log(err);
return;
}
console.log('Listening at http://localhost:' + port + '\n');
console.log(`Listening at http://localhost:${port}\n`);
});