Skip to content

Instantly share code, notes, and snippets.

@dcurletti
Created February 18, 2016 06:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcurletti/cc4dc7d9bfcad63d389a to your computer and use it in GitHub Desktop.
Save dcurletti/cc4dc7d9bfcad63d389a to your computer and use it in GitHub Desktop.
Build AngularJS 1.x with Webpack and ES6
import Vendor from './vendor';
angular.module('appName', ['dependencies']).config( ('providers') => {
//defined routes, etc.
});
// This is explicitly called so that the app 'appName' is available when you require the rest of your Angular files
Vendor()
const $el = document.getElementById('elementWithNgApp') || document;
angular.bootstrap($el, 'appName')
/////////////////////
// Change from this:
/////////////////////
//= require src/partial/homebuyers/map-search/map-search.nav-mobile/map-search.nav-mobile.js
//= require src/partial/homebuyers/map-search/map-search.search-bar/map-search.search-bar.js
//= require src/partial/agents/action-items/action-items.js
//= require src/filter/shared/mls-memberships.js
//= require src/filter/shared/constantize.js
//= require src/filter/shared/school-level.js
///////////
// To this:
///////////
export default function() {
var templates = require.context('./src', true, /\.html$/);
templates.keys().map(templates);
var context = require.context('./src', true, /^((?!-spec).)*js$/);
context.keys().map(context);
};
// ngtemplate automatically runs each html file through the $templateCache, and depending on how you
// require it, you will need to trim parts of the path
var angularPath = __dirname + '/src/';
config.module.loaders = [
{
test: /\/rs-ui\/src\/.+\.html$/,
exclude: /node_modules/,
loaders: ['ngtemplate?relativeTo=' + angularPath, 'html?attrs=false']
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ['babel-loader']
}
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment