Created
February 18, 2016 06:06
-
-
Save dcurletti/cc4dc7d9bfcad63d389a to your computer and use it in GitHub Desktop.
Build AngularJS 1.x with Webpack and ES6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////// | |
// 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); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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