Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

Commit e9b01e3

Browse files
committed
example of using the project with webpack and commonJS, this should not be hard to figure out with browserify
1 parent 3abaf00 commit e9b01e3

File tree

6 files changed

+114
-4
lines changed

6 files changed

+114
-4
lines changed

Gruntfile.coffee

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = (grunt) ->
5151
grunt.initConfig options
5252

5353
grunt.registerTask 'build', ['bower', 'clean:dist', 'jshint', 'mkdir', 'coffee', 'ngAnnotate',
54-
'concat:libs', 'replace', 'webpack']
54+
'concat:libs', 'replace', 'webpack:commonjsDeps']
5555

5656
grunt.registerTask 'buildDist', ['build', 'concat:dist']
5757

@@ -72,7 +72,7 @@ module.exports = (grunt) ->
7272

7373
grunt.registerTask 'offline', ['default-no-specs', 'watch:offline']
7474

75-
dev = ["clean:dist", "jshint", "mkdir", "coffee", "concat:libs", "replace", "webpack", "concat", "copy"]
75+
dev = ["clean:dist", "jshint", "mkdir", "coffee", "concat:libs", "replace", "webpack:commonjsDeps", "concat", "copy"]
7676

7777
grunt.registerTask "dev", dev.concat ["uglify:distMapped", "uglify:streetviewMapped", "karma"]
7878

@@ -131,6 +131,11 @@ module.exports = (grunt) ->
131131
logFn: grunt.log.oklns
132132
configFile: require.resolve './karma.conf.coffee'
133133

134+
grunt.registerTask 'karma:acceptance', 'karma runner', ->
135+
kickoff @async(),
136+
logFn: grunt.log.oklns
137+
configFile: require.resolve './karma.acceptance.conf.coffee'
138+
134139
grunt.registerTask 'karmaSpecific', 'karma runner', ->
135140
kickoff @async(),
136141
configFile: require.resolve './karma.conf.coffee'

grunt/options/webpack.coffee

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
webpack = require 'webpack'
12
module.exports =
23
# for commonjs libraries that need to be rolled in
34
webpack:
@@ -8,3 +9,17 @@ module.exports =
89
#Make sure to use [name] or [id] in output.filename
910
path: "tmp/"
1011
filename: "webpack.[name].js",
12+
13+
acceptance:
14+
entry:
15+
acceptance: "./spec/js/acceptance/app.js",
16+
output:
17+
#Make sure to use [name] or [id] in output.filename
18+
path: "tmp/acceptance"
19+
filename: "webpack.[name].js",
20+
externals:
21+
_ : "lodash"
22+
plugins: [
23+
new webpack.ProvidePlugin
24+
_ : "lodash"
25+
]

karma.acceptance.conf.coffee

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
2+
module.exports = (config) ->
3+
config.set
4+
# base path that will be used to resolve all patterns (eg. files, exclude)
5+
basePath: './'
6+
7+
# frameworks to use
8+
# available frameworks: https://npmjs.org/browse/keyword/karma-adapter
9+
frameworks: ['jasmine']
10+
11+
# preprocess matching files before serving them to the browser
12+
# available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
13+
preprocessors: {
14+
# 'spec/**/*.coffee': ['coffee']
15+
'spec/**/**/*.coffee': ['coffee']
16+
}
17+
18+
# list of files / patterns to load in the browser
19+
files: [
20+
# 'https://maps.googleapis.com/maps/api/js?sensor=false'
21+
'node_modules/phantomjs-polyfill/bind-polyfill.js'
22+
'./tmp/acceptance/webpack.acceptance.js'
23+
'bower_components/angular-mocks/angular-mocks.js'
24+
'spec/coffee/bootstrap/bootstrap.coffee'
25+
'spec/coffee/bootstrap/google-api-mock.coffee'
26+
'spec/coffee/bootstrap/initiator.coffee'
27+
#do not include those specs for jasmine html runner by karma kama_jasmine_runner.html
28+
{pattern:'*coffee', included: false}
29+
'spec/coffee/**/*.spec.coffee'
30+
]
31+
32+
# list of files to exclude
33+
exclude: [
34+
]
35+
36+
# test results reporter to use
37+
# possible values: 'dots', 'progress'
38+
# available reporters: https://npmjs.org/browse/keyword/karma-reporter
39+
# NOTE , TODO 'html' reporter use if you want to hit the karma jasmine runner (frequently causes karma to blow up at the end of run),
40+
# test results reporter to use
41+
# possible values: 'dots', 'progress', 'mocha'
42+
reporters: ['mocha', 'coverage']
43+
44+
# web server port
45+
port: 9876
46+
47+
# enable / disable colors in the output (reporters and logs)
48+
colors: true
49+
50+
# level of logging
51+
# possible values:
52+
# - config.LOG_DISABLE
53+
# - config.LOG_ERROR
54+
# - config.LOG_WARN
55+
# - config.LOG_INFO
56+
# - config.LOG_DEBUG
57+
logLevel: config.LOG_INFO
58+
59+
# enable / disable watching file and executing tests whenever any file changes
60+
autoWatch: false
61+
62+
# start these browsers
63+
# available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
64+
browsers: process.env.KARMA_BROWSERS?.split(',') ? ['PhantomJS']# options Chrome, PhantomJS
65+
#browserNoActivityTimeout: 200000000000000000000000000000000
66+
# If browser does not capture in given timeout [ms], kill it
67+
captureTimeout: 60000
68+
# Continuous Integration mode
69+
# if true, Karma captures browsers, runs the tests and exits
70+
singleRun: false
71+
72+
plugins: [
73+
'karma-mocha-reporter'
74+
'karma-jasmine'
75+
'karma-coverage'
76+
'karma-chrome-launcher'
77+
'karma-phantomjs-launcher'
78+
'karma-coffee-preprocessor'
79+
]

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
"devDependencies": {
3131
"bower": "~1.4.1",
3232
"data-structures": "^1.4.2",
33+
"eslint": "3.7.1",
34+
"eslint-config-airbnb": "12.0.0",
35+
"eslint-plugin-import": "1.16.0",
36+
"eslint-plugin-jsx-a11y": "2.2.2",
37+
"eslint-plugin-react": "6.3.0",
3338
"grunt": "~0.4.5",
3439
"grunt-angular-architecture-graph": "^0.2.6",
3540
"grunt-bump": "0.3.1",
@@ -69,8 +74,8 @@
6974
"mocha": "2.X",
7075
"phantomjs-polyfill": "0.0.1",
7176
"require-directory": "2.1.1",
72-
"webpack": "^1.9.10",
73-
"webpack-dev-server": "^1.14.1",
77+
"webpack": "1.X",
78+
"webpack-dev-server": "1.X",
7479
"yargs": "3.32.0"
7580
},
7681
"dependencies": {

spec/js/acceptance/app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var angular = require('angular');
2+
require('../../../dist/angular-google-maps.js');
3+
require('angular-simple-logger');

src/js/acceptance/app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require('expose?angular');
2+
require('../../../dist/angular-google-maps.js');
3+
require('angular-simple-logger');

0 commit comments

Comments
 (0)