Skip to content

Instantly share code, notes, and snippets.

@brickpop
Last active May 5, 2017 11:08
Show Gist options
  • Save brickpop/9866043403de8a46e3d2411f110eafbb to your computer and use it in GitHub Desktop.
Save brickpop/9866043403de8a46e3d2411f110eafbb to your computer and use it in GitHub Desktop.
Build ng-admin with Webpack
// CSS
require('../node_modules/ng-admin/build/ng-admin.min.css');
// ALL IN ONE
require('ng-admin/build/ng-admin-only.min');
// JS
// var angular = require('angular/angular.min.js');
require('angular-ui-bootstrap/dist/ui-bootstrap-tpls.js');
require('angular-bootstrap/ui-bootstrap.min');
require('angular-resource/angular-resource.min');
// require('angular-sanitize/angular-sanitize.min');
require('angular-translate/dist/angular-translate.min.js');
require('angular-ui-codemirror/src/ui-codemirror');
require('angular-ui-router/release/angular-ui-router.min');
require('angular-numeraljs/dist/angular-numeraljs.min');
window._ = require('underscore/underscore-min');
require('humane-js/humane.min');
require('inflection/inflection.min');
require('ng-file-upload/dist/ng-file-upload.min.js');
require('nginflection/index.js');
require('nprogress/nprogress');
require('restangular/dist/restangular.min');
window.taTools = {};
require('textangular/dist/textAngular-sanitize.min.js');
require('textangular/src/textAngularSetup.js');
require('textangular/src/globals.js');
require('textangular/src/factories.js');
require('textangular/src/validators.js');
require('textangular/src/DOM.js');
require('textangular/src/taBind.js');
require('textangular/src/main.js');
require('papaparse/papaparse.min');
require('numeral/min/numeral.min.js');
require('codemirror/lib/codemirror');
require('codemirror/addon/edit/closebrackets');
require('codemirror/addon/lint/lint');
require('jsonlint/lib/jsonlint');
require('ui-select/index.js');
require('codemirror/addon/lint/json-lint');
require('codemirror/addon/selection/active-line');
require('codemirror/mode/javascript/javascript');
var theApp = angular.module('crmApp', ['ng-admin']);
theApp.factory('httpInterceptor', ['$q', '$injector', 'notification', function($q, $injector, notification) {
return {
'responseError': function(rejection) {
if (rejection.status === 401) {
notification.log('Your session timed-out', { addnCls: 'humane-flatty-error' });
$injector.get('$state').go('logout');
}
if (rejection.status === 403) {
notification.log('You are not authorized to access this function ', { addnCls: 'humane-flatty-error' });
$injector.get('$state').go('dashboard');
}
// Replace response with rejected promise to prevent rest of execution
return $q.reject(rejection);
}
};
}]);
theApp.config(['NgAdminConfigurationProvider', '$stateProvider', '$translateProvider', '$httpProvider', function(NgAdminConfigurationProvider, $stateProvider, $translateProvider, $httpProvider) {
$httpProvider.interceptors.push('httpInterceptor');
var nga = NgAdminConfigurationProvider;
var admin = nga.application("Backend")
.baseApiUrl("/api/");
// ENTITIES
admin.addEntity(nga.entity('categories'));
admin.addEntity(nga.entity('questions'));
//admin.addEntity(nga.entity('categories'));
require('./categories')(nga, admin);
require('./questions')(nga, admin);
// CONFIG
nga.configure(admin);
// LANGUAGE
require('./language')($translateProvider);
}]);
{
"name": "Tvrbo Admin",
"version": "1.0.0",
"description": "NG-ADMIN",
"main": "index.js",
"scripts": {
"make": "webpack --config webpack.config.js",
"watch": "webpack --watch --config webpack.config.js",
"start": "npm run make && node server.js",
"dev": "npm run watch & nodemon --watch api --watch lib --watch models server.js"
},
"engines": {
"node": "6.3.1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"angular": "^1.5.8",
"angular-bootstrap": "^0.12.2",
"angular-chart.js": "^1.0.0-alpha8",
"angular-numeraljs": "^1.3.1",
"angular-resource": "^1.5.8",
"angular-sanitize": "^1.5.8",
"angular-translate": "^2.11.1",
"angular-ui-bootstrap": "^2.0.1",
"angular-ui-codemirror": "^0.3.0",
"angular-ui-router": "^0.3.1",
"bluebird": "^3.4.0",
"body-parser": "^1.15.1",
"bootstrap": "^3.3.7",
"codemirror": "^5.17.0",
"css-loader": "^0.23.1",
"express": "^4.13.4",
"file": "^0.2.2",
"file-loader": "^0.9.0",
"googleapis": "^9.0.0",
"html-loader": "^0.4.3",
"humane-js": "^3.2.2",
"img-loader": "^1.3.1",
"inflection": "^1.10.0",
"json-loader": "^0.5.4",
"jsonlint": "^1.6.2",
"method-override": "^2.3.6",
"mongoose": "^4.4.17",
"nconf": "^0.8.4",
"ng-admin": "^1.0.0-alpha2",
"ng-file-upload": "^12.0.4",
"nginflection": "^1.1.10",
"nprogress": "^0.2.0",
"numeral": "^1.5.3",
"opn": "^4.0.2",
"papaparse": "^4.1.2",
"restangular": "^1.5.2",
"run-sequence": "^1.2.0",
"serve-static": "^1.10.2",
"style-loader": "^0.13.1",
"system": "^1.0.6",
"textangular": "^1.5.3",
"ui-select": "^0.18.1",
"underscore": "^1.8.3",
"url-loader": "^0.5.7",
"webpack": "^1.13.1"
},
"devDependencies": {
"nodemon": "^1.9.2"
}
}
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: './src/index.js',
output: {
path: path.join(__dirname, 'build'),
filename: 'app.bundle.js'
},
module: {
loaders: [
// MEDIA
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'url?limit=8192',
'img'
]
},
{
test: /\.css$/,
loader: "style-loader!css-loader"
},{
test: /\.html$/,
loader: "html"
},
{
test: /\.(woff|woff2)$/,
loader: "url-loader?limit=10000&mimetype=application/font-woff"
},
{
test: /\.ttf$/,
loader: "file-loader"
},
{
test: /\.eot$/,
loader: "file-loader"
},
{
test: /\.json$/,
loader: "json-loader"
}
]
},
node: {
fs: 'empty'
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"',
'NODE_ENV': '"production"'
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin()
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment