Skip to content

Commit

Permalink
bug fix in authservice and webpack setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottBrenden committed Jun 19, 2017
1 parent 6fd64af commit 49b86f4
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/node_modules/*
**/vendor/*
**/*.min.js
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,8 @@ Session.vim
# auto-generated tag files
tags

#dotenv
# dotenv
.env

# build files
build/
6 changes: 3 additions & 3 deletions app/service/auth-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = [

if(!token) return $q.reject(new Error('No Token'));
$window.localStorage.setItem('token', token);
tempToken = token;
let tempToken = token;

return $q.resolve(tempToken);
}
Expand All @@ -42,7 +42,7 @@ module.exports = [
},
};

return $http.get(url, config)
return $http.get(url, user, config)
.then(res => {
// $log.log('sucess', res.data);
return setToken(res.data);
Expand Down Expand Up @@ -73,7 +73,7 @@ module.exports = [
.catch(err => {
$log.error('failure', err.message);
return $q.reject(err);
})
});
};

service.logout = function(){
Expand Down
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,21 @@
"dependencies": {
"@uirouter/angularjs": "^1.0.4",
"angular": "^1.6.4",
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-preset-es2015": "^6.24.1",
"camelcase": "^4.1.0",
"clean-webpack-plugin": "^0.1.16",
"dotenv": "^4.0.0",
"extract-text-webpack-plugin": "^2.1.2",
"html-loader": "^0.4.5",
"html-webpack-plugin": "^2.28.0",
"node-sass": "^4.5.3",
"pascalcase": "^0.1.1",
"path": "^0.12.7",
"resolve-url-loader": "^2.0.2",
"sass-loader": "^6.0.6",
"style-loader": "^0.18.2",
"webpack": "^3.0.0"
"url-loader": "^0.5.8",
"webpack": "^2.6.1"
}
}
74 changes: 74 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
'use strict';

require('dotenv').load();

const webpack = require('webpack');
const HTMLPlugin = require('html-webpack-plugin');
const CleanPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');

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

let plugins = [
new ExtractTextPlugin({filename: 'bundle.css'}),
new HTMLPlugin({template: `${__dirname}/app/index.html`}),
new webpack.DefinePlugin({
__API_URL__: JSON.stringify(process.env.API_URL),
__DEBUG__: JSON.stringify(!production),
}),
];

if(production){
plugins = plugins.concat([
new webpack.optimize.UglifyJsPlugin({
mangle: true,
compress: {warnings: false},
}),
new CleanPlugin(),
]);
}

module.exports = {
entry: `${__dirname}/app/entry.js`,
devtool: production ? false : 'source-map',
output: {
filename: 'bundle.js',
path: `${__dirname}/build`,
},
plugins,
module: {
loaders: [
{
test:/\.js$/,
exclude: /node-modules/,
use: ['babel-loader'],
},
{
test: /\.html$/,
use: ['html-loader'],
},
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {sourceMap:true},
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
includePaths: [`${__dirname}/app/scss`],
},
},
],
}),
},
{
test: /\.(woff|ttf|svg|eot).*/,
use: 'url-loader?limit=10000&name=image/[hash].[ext]',
},
],
},
};

0 comments on commit 49b86f4

Please sign in to comment.