conjur-asset-ui 1.4.2 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +8 -3
  3. data/CHANGELOG.md +10 -0
  4. data/Makefile +19 -0
  5. data/README.md +0 -3
  6. data/Rakefile +22 -17
  7. data/TODO.md +0 -23
  8. data/app/.csscomb.json +304 -0
  9. data/app/.eslintignore +3 -0
  10. data/app/.eslintrc +265 -0
  11. data/app/config/preprocessor.js +19 -0
  12. data/app/config/webpack.js +124 -0
  13. data/app/gulpfile.js +96 -0
  14. data/app/package.json +86 -0
  15. data/app/src/actions.js +550 -0
  16. data/app/src/app.js +83 -0
  17. data/app/src/clients/audit.js +34 -0
  18. data/app/src/clients/auth.js +24 -0
  19. data/app/src/clients/generic.js +52 -0
  20. data/app/src/clients/graph.js +7 -0
  21. data/app/src/clients/layer_members.js +18 -0
  22. data/app/src/clients/list.js +31 -0
  23. data/app/src/clients/members.js +20 -0
  24. data/app/src/clients/request.js +531 -0
  25. data/app/src/clients/search.js +5 -0
  26. data/app/src/components/app/__tests__/app-test.js +22 -0
  27. data/app/src/components/app/app.js +36 -0
  28. data/app/src/components/app/wrapper.js +17 -0
  29. data/app/src/components/audit/__tests__/table_header-test.js +22 -0
  30. data/app/src/components/audit/box.js +9 -0
  31. data/app/src/components/audit/constants.js +5 -0
  32. data/app/src/components/audit/entry.js +105 -0
  33. data/app/src/components/audit/fields_mixin.js +11 -0
  34. data/app/src/components/audit/humanize_event.js +213 -0
  35. data/app/src/components/audit/table.js +64 -0
  36. data/app/src/components/audit/table_header.js +37 -0
  37. data/app/src/components/audit/timestamp.js +28 -0
  38. data/app/src/components/auth/login.js +177 -0
  39. data/app/src/components/auth/login.less +71 -0
  40. data/app/src/components/auth/logout.js +42 -0
  41. data/app/src/components/auth/logout.less +21 -0
  42. data/app/src/components/chart/chart.js +540 -0
  43. data/app/src/components/chart/chart_helper_mixin.js +78 -0
  44. data/app/src/components/custom/list.js +3 -0
  45. data/app/src/components/custom/view.js +81 -0
  46. data/app/src/components/dashboard/activity.js +144 -0
  47. data/app/src/components/dashboard/dashboard.js +46 -0
  48. data/app/src/components/flash/flash.js +98 -0
  49. data/app/src/components/flash/flash.less +3 -0
  50. data/app/src/components/generic/__tests__/time-test.js +42 -0
  51. data/app/src/components/generic/annotations.js +39 -0
  52. data/app/src/components/generic/breadcrumbs.js +57 -0
  53. data/app/src/components/generic/foldable_audit_section.js +204 -0
  54. data/app/src/components/generic/list.js +141 -0
  55. data/app/src/components/generic/list_factory.js +41 -0
  56. data/app/src/components/generic/resource_link.js +64 -0
  57. data/app/src/components/generic/role_link.js +66 -0
  58. data/app/src/components/generic/tab_mixin.js +146 -0
  59. data/app/src/components/generic/time.js +32 -0
  60. data/app/src/components/graph/__tests__/collapse-test.js +133 -0
  61. data/app/src/components/graph/__tests__/edges-from-vertices-test.js +48 -0
  62. data/app/src/components/graph/__tests__/new-vertex-set-test.js +16 -0
  63. data/app/src/components/graph/__tests__/next-id-test.js +27 -0
  64. data/app/src/components/graph/__tests__/role-kind-from-id-test.js +24 -0
  65. data/app/src/components/graph/__tests__/vertices-from-edges-test.js +72 -0
  66. data/app/src/components/graph/graph.js +449 -0
  67. data/app/src/components/graph/graph.less +39 -0
  68. data/app/src/components/graph/helpers.js +368 -0
  69. data/app/src/components/group/list.js +3 -0
  70. data/app/src/components/group/view.js +153 -0
  71. data/app/src/components/host/activity.js +111 -0
  72. data/app/src/components/host/details.js +28 -0
  73. data/app/src/components/host/executors.js +77 -0
  74. data/app/src/components/host/host_link.js +18 -0
  75. data/app/src/components/host/list.js +3 -0
  76. data/app/src/components/host/updaters.js +77 -0
  77. data/app/src/components/host/view.js +145 -0
  78. data/app/src/components/layer/list.js +3 -0
  79. data/app/src/components/layer/view.js +197 -0
  80. data/app/src/components/navbar/__tests__/navbar-test.js +21 -0
  81. data/app/src/components/navbar/nav_search_form.js +40 -0
  82. data/app/src/components/navbar/navbar.js +96 -0
  83. data/app/src/components/notfound/notfound.js +35 -0
  84. data/app/src/components/notfound/notfound.less +21 -0
  85. data/app/src/components/owned_resources/owned_resources.js +84 -0
  86. data/app/src/components/owned_resources/owned_resources_box.js +101 -0
  87. data/app/src/components/permissions/permissions.js +138 -0
  88. data/app/src/components/permissions/permissions_table.js +101 -0
  89. data/app/src/components/policy/list.js +3 -0
  90. data/app/src/components/policy/view.js +107 -0
  91. data/app/src/components/refresh/refresh.js +29 -0
  92. data/app/src/components/refresh/refresh.less +15 -0
  93. data/app/src/components/search/group.js +43 -0
  94. data/app/src/components/search/group_heading.js +50 -0
  95. data/app/src/components/search/group_title.js +37 -0
  96. data/app/src/components/search/result_item.js +55 -0
  97. data/app/src/components/search/search.js +118 -0
  98. data/app/src/components/user/activity.js +112 -0
  99. data/app/src/components/user/details.js +30 -0
  100. data/app/src/components/user/list.js +3 -0
  101. data/app/src/components/user/pubkeys.js +118 -0
  102. data/app/src/components/user/pubkeys.less +56 -0
  103. data/app/src/components/user/view.js +143 -0
  104. data/app/src/components/variable/activity.js +101 -0
  105. data/app/src/components/variable/details.js +46 -0
  106. data/app/src/components/variable/fetchers.js +77 -0
  107. data/app/src/components/variable/list.js +3 -0
  108. data/app/src/components/variable/updaters.js +77 -0
  109. data/app/src/components/variable/view.js +115 -0
  110. data/app/src/constants.js +36 -0
  111. data/{public → app/src}/images/conjur-logo.svg +0 -0
  112. data/{public → app/src}/images/icon-client-pc.svg +0 -0
  113. data/{public → app/src}/images/icon-environment.png +0 -0
  114. data/{public → app/src}/images/icon-person.svg +0 -0
  115. data/{public → app/src}/images/icon-policy.png +0 -0
  116. data/{public → app/src}/images/icon-resource.png +0 -0
  117. data/{public → app/src}/images/icon-service-dots.svg +0 -0
  118. data/{public → app/src}/images/icon-variable.png +0 -0
  119. data/app/src/pages/index.html +27 -0
  120. data/app/src/routes.js +64 -0
  121. data/app/src/stores/app_store.js +35 -0
  122. data/app/src/stores/audit_store.js +143 -0
  123. data/app/src/stores/graph_store.js +51 -0
  124. data/app/src/stores/group_store.js +104 -0
  125. data/app/src/stores/host_store.js +111 -0
  126. data/app/src/stores/layer_store.js +115 -0
  127. data/app/src/stores/policy_store.js +88 -0
  128. data/app/src/stores/resources_store.js +115 -0
  129. data/app/src/stores/route_store.js +21 -0
  130. data/app/src/stores/search_store.js +77 -0
  131. data/app/src/stores/user_store.js +109 -0
  132. data/app/src/stores/variable_store.js +93 -0
  133. data/app/src/styles/bootstrap.less +54 -0
  134. data/{public/css → app/src/styles}/styles.less +26 -82
  135. data/app/src/utils.js +38 -0
  136. data/app/src/vendor/pace.js +2 -0
  137. data/conjur-asset-ui.gemspec +3 -4
  138. data/docker/assets-build/Dockerfile +12 -0
  139. data/docker/conjur-ui/Dockerfile +33 -0
  140. data/docker/conjur-ui/README.md +38 -0
  141. data/docker/conjur-ui/mime.types +90 -0
  142. data/docker/conjur-ui/nginx.conf +110 -0
  143. data/docker/conjur-ui/start.py +72 -0
  144. data/docker/conjur-ui/start.sh +18 -0
  145. data/docker/conjur-ui/test.env +8 -0
  146. data/lib/conjur-asset-ui-version.rb +1 -1
  147. data/lib/conjur/command/ui.rb +10 -2
  148. data/lib/conjur/webserver/home.rb +3 -3
  149. data/lib/conjur/webserver/login.rb +1 -1
  150. data/lib/conjur/webserver/server.rb +16 -4
  151. data/public/js/views/roleGraph.js +91 -0
  152. metadata +167 -105
  153. data/.jshintrc +0 -41
  154. data/bower.json +0 -98
  155. data/gulpfile.js +0 -139
  156. data/package.json +0 -47
  157. data/preprocessor.js +0 -7
  158. data/public/_client_libs.html +0 -9
  159. data/public/index.html.erb +0 -63
  160. data/public/js/init.js +0 -196
  161. data/public/js/lib/pace.js +0 -2
  162. data/public/js/lib/sorted-set.no-require.js +0 -1145
  163. data/public/js/lib/sorted-set.no-require.js.txt +0 -6
  164. data/public/js/models/groupRecord.js +0 -72
  165. data/public/js/models/hostRecord.js +0 -60
  166. data/public/js/models/layerRecord.js +0 -79
  167. data/public/js/models/namespace.js +0 -12
  168. data/public/js/models/policyList.js +0 -16
  169. data/public/js/models/policyRecord.js +0 -54
  170. data/public/js/models/record.js +0 -117
  171. data/public/js/models/resourceList.js +0 -87
  172. data/public/js/models/userList.js +0 -25
  173. data/public/js/models/userRecord.js +0 -75
  174. data/public/js/models/variableList.js +0 -27
  175. data/public/js/models/variableRecord.js +0 -77
  176. data/public/js/routers.js +0 -242
  177. data/public/js/views/annotations.js +0 -47
  178. data/public/js/views/audit.js +0 -369
  179. data/public/js/views/breadcrumbs.js +0 -62
  180. data/public/js/views/chart.js +0 -617
  181. data/public/js/views/dashboard.js +0 -146
  182. data/public/js/views/generic.js +0 -122
  183. data/public/js/views/group.js +0 -109
  184. data/public/js/views/groups.js +0 -26
  185. data/public/js/views/host.js +0 -200
  186. data/public/js/views/hosts.js +0 -26
  187. data/public/js/views/layer.js +0 -146
  188. data/public/js/views/layers.js +0 -26
  189. data/public/js/views/mixins/search.js +0 -22
  190. data/public/js/views/mixins/tabs.js +0 -154
  191. data/public/js/views/namespaces.js +0 -40
  192. data/public/js/views/navSearch.js +0 -36
  193. data/public/js/views/owned.js +0 -184
  194. data/public/js/views/permissions.js +0 -254
  195. data/public/js/views/policies.js +0 -26
  196. data/public/js/views/policy.js +0 -70
  197. data/public/js/views/resource.js +0 -59
  198. data/public/js/views/role.js +0 -63
  199. data/public/js/views/searchResults.js +0 -212
  200. data/public/js/views/sections.js +0 -226
  201. data/public/js/views/time.js +0 -39
  202. data/public/js/views/user.js +0 -297
  203. data/public/js/views/users.js +0 -26
  204. data/public/js/views/variable.js +0 -310
  205. data/public/js/views/variables.js +0 -26
  206. data/spec/javascripts/helpers/.gitkeep +0 -0
  207. data/spec/javascripts/support/jasmine.yml +0 -112
  208. data/spec/javascripts/support/jasmine_helper.rb +0 -22
  209. data/spec/javascripts/support/run.html.erb +0 -23
  210. data/spec/javascripts/views/AuditSpec.js +0 -22
  211. data/spec/javascripts/views/AuditSpec.ls +0 -18
@@ -0,0 +1,3 @@
1
+ src/vendor/*
2
+ src/components/graph/graph.js
3
+ src/**/__tests__/*.js
@@ -0,0 +1,265 @@
1
+ {
2
+ "parser": "babel-eslint",
3
+ "env": {
4
+ "browser": true,
5
+ "node": true,
6
+ "es6": true
7
+ },
8
+ "ecmaFeatures": {
9
+ "modules": true
10
+ },
11
+ "globals": {
12
+ "__DEV__": true
13
+ },
14
+ "plugins": [
15
+ "react"
16
+ ],
17
+ "rules": {
18
+ // Possible Errors
19
+ // The following rules point out areas where you might have made mistakes.
20
+ "comma-dangle": [2, "never"],
21
+ "no-cond-assign": [2, "except-parens"],
22
+ "no-console": [1],
23
+ "no-constant-condition": [2],
24
+ "no-control-regex": [2],
25
+ "no-debugger": [2],
26
+ "no-dupe-args": [2],
27
+ "no-dupe-keys": [2],
28
+ "no-duplicate-case": [2],
29
+ "no-empty": [2],
30
+ "no-empty-class": [2],
31
+ "no-ex-assign": [2],
32
+ "no-extra-boolean-cast": [2],
33
+ "no-extra-parens": [0],
34
+ "no-extra-semi": [2],
35
+ "no-func-assign": [2],
36
+ "no-inner-declarations": [2],
37
+ "no-invalid-regexp": [2],
38
+ "no-irregular-whitespace": [2],
39
+ "no-negated-in-lhs": [2],
40
+ "no-obj-calls": [2],
41
+ "no-regex-spaces": [2],
42
+ "no-reserved-keys": [2],
43
+ "no-sparse-arrays": [2],
44
+ "no-unreachable": [2],
45
+ "use-isnan": [2],
46
+ "valid-jsdoc": [1], // TODO: inspect options
47
+ "valid-typeof": [2],
48
+
49
+ // Best Practices
50
+ // These are rules designed to prevent you from making mistakes.
51
+ // They either prescribe a better way of doing something or help you avoid footguns.
52
+ "block-scoped-var": [0], // TODO: 1
53
+ "complexity": [1, 15],
54
+ "consistent-return": [2],
55
+ "curly": [2, "all"],
56
+ "default-case": [1],
57
+ "dot-notation": [2, {"allowPattern": "^[a-z]+(_[a-z]+)+$"}],
58
+ "eqeqeq": [2],
59
+ // guard-for-in TODO
60
+ "no-alert": [2],
61
+ "no-caller": [2],
62
+ "no-div-regex": [2],
63
+ "no-else-return": [0],
64
+ "no-empty-label": [1],
65
+ "no-eq-null": [2],
66
+ "no-eval": [2],
67
+ "no-extend-native": [2],
68
+ "no-extra-bind": [2],
69
+ "no-fallthrough": [2],
70
+ "no-floating-decimal": [2],
71
+ "no-implied-eval": [2],
72
+ "no-iterator": [1], // TODO Babel polyfill
73
+ "no-labels": [0],
74
+ "no-lone-blocks": [2],
75
+ "no-loop-func": [2],
76
+ "no-multi-spaces": [2],
77
+ "no-multi-str": [2],
78
+ "no-native-reassign": [2],
79
+ "no-new": [2],
80
+ "no-new-func": [2],
81
+ "no-new-wrappers": [2],
82
+ "no-octal": [2],
83
+ "no-octal-escape": [2],
84
+ "no-param-reassign": [2],
85
+ "no-process-env": [0],
86
+ "no-proto": [2],
87
+ "no-redeclare": [2],
88
+ "no-return-assign": [2],
89
+ "no-script-url": [2],
90
+ "no-self-compare": [2],
91
+ "no-sequences": [2],
92
+ "no-throw-literal": [2],
93
+ "no-unused-expressions": [2],
94
+ "no-void": [2],
95
+ // no-warning-comments TODO
96
+ "no-with": [2],
97
+ "radix": [0],
98
+ "vars-on-top": [0], // has problems with module high level variables
99
+ "wrap-iife": [2, "inside"],
100
+ "yoda": [2, "never", { "exceptRange": true }],
101
+
102
+ // Strict Mode
103
+ // These rules relate to using strict mode.
104
+ "strict": [2, "global"],
105
+
106
+ // Variables
107
+ // These rules have to do with variable declarations.
108
+ "no-catch-shadow": [0],
109
+ "no-delete-var": [2],
110
+ "no-label-var": [2],
111
+ "no-shadow": [2],
112
+ "no-shadow-restricted-names": [2],
113
+ "no-undef": [2],
114
+ "no-undef-init": [2],
115
+ "no-undefined": [1],
116
+ "no-unused-vars": [2, {"vars": "all", "args": "after-used"}],
117
+ "no-use-before-define": [2],
118
+
119
+ // Node.js
120
+ // These rules are specific to JavaScript running on Node.js.
121
+ "handle-callback-err": [1],
122
+ "no-mixed-requires": [1, true], // TODO: enfource grouping
123
+ "no-new-require": [2],
124
+ "no-path-concat": [2],
125
+ "no-process-exit": [2],
126
+ "no-restricted-modules": [
127
+ 2,
128
+ "assert",
129
+ "buffer",
130
+ "child_process",
131
+ "cluster",
132
+ "crypto",
133
+ "dgram",
134
+ "dns",
135
+ "domain",
136
+ "events",
137
+ "freelist",
138
+ "fs",
139
+ "http",
140
+ "https",
141
+ "module",
142
+ "net",
143
+ "os",
144
+ "path",
145
+ "punycode",
146
+ "querystring",
147
+ "readline",
148
+ "repl",
149
+ "smalloc",
150
+ "stream",
151
+ "string_decoder",
152
+ "sys",
153
+ "timers",
154
+ "tls",
155
+ "tracing",
156
+ "tty",
157
+ "url",
158
+ "util",
159
+ "vm",
160
+ "zlib"
161
+ ],
162
+ "no-sync": [2],
163
+
164
+ // Stylistic Issues
165
+ // These rules are purely matters of style and are quite subjective.
166
+ "indent": [2, 4, {"indentSwitchCase": false}],
167
+ "brace-style": [2, "1tbs", {"allowSingleLine": false}],
168
+ "camelcase": [2, {"properties": "always"}],
169
+ "comma-spacing": [2, {"before": false, "after": true}],
170
+ "comma-style": [2, "last"],
171
+ "consistent-this": [1, "self"],
172
+ "eol-last": [1],
173
+ "eol-last": [2],
174
+ // func-names
175
+ // func-style
176
+ "key-spacing": [2, {"beforeColon": false, "afterColon": true}],
177
+ "max-nested-callbacks": [2, 3],
178
+ "new-cap": [2,
179
+ {
180
+ "newIsCap": true,
181
+ "capIsNew": true,
182
+ "capIsNewExceptions": [
183
+ "Array",
184
+ "Boolean",
185
+ "Date",
186
+ "Error",
187
+ "Function",
188
+ "Number",
189
+ "Object",
190
+ "RegExp",
191
+ "String",
192
+ "Symbol",
193
+ "FluxMixin",
194
+ "StoreWatchMixin"
195
+ ]
196
+ }
197
+ ],
198
+ "new-parens": [2],
199
+ // "newline-after-var": [2, "always"],
200
+ "no-array-constructor": [2],
201
+ "no-inline-comments": [1],
202
+ "no-lonely-if": [2],
203
+ "no-mixed-spaces-and-tabs": [2],
204
+ "no-multiple-empty-lines": [2, {"max": 1}],
205
+ "no-nested-ternary": [2],
206
+ "no-new-object": [2],
207
+ "no-spaced-func": [2],
208
+ "no-ternary": [0],
209
+ "no-trailing-spaces": [2],
210
+ "no-underscore-dangle": [0],
211
+ "no-wrap-func": [2],
212
+ // one-var
213
+ "operator-assignment": [2, "always"],
214
+ // "padded-blocks": [2, "never"],
215
+ "quote-props": [2, "as-needed"],
216
+ "quotes": [2, "single"],
217
+ "semi": [2, "always"],
218
+ "semi-spacing": [2, {"before": false, "after": true}],
219
+ // sort-vars
220
+ "space-after-keywords": [2, "always"],
221
+ "space-before-blocks": [2, "always"],
222
+ "space-before-function-paren": [2, "never"],
223
+ // "space-in-brackets": [2, "never"], won't work in eslint 0.20 due https://github.com/eslint/eslint/issues/2378
224
+ "space-in-parens": [2, "never"],
225
+ "space-infix-ops": [2, {"int32Hint": false}],
226
+ "space-return-throw-case": [2],
227
+ "space-unary-ops": [2, {"words": true, "nonwords": false}],
228
+ "spaced-line-comment": [2, "always", {"exceptions": ["-"]}],
229
+ "wrap-regex": [0],
230
+
231
+ // ECMAScript 6
232
+ // These rules are only relevant to ES6 environments and are off by default.
233
+ "no-var": [0],
234
+ "generator-star-spacing": [2, "after"],
235
+
236
+ // Legacy
237
+ // The following rules are included for compatibility with JSHint and JSLint.
238
+ // While the names of the rules may not match up with the JSHint/JSLint counterpart,
239
+ // the functionality is the same.
240
+ // max-depth
241
+ // max-len
242
+ // max-params
243
+ // max-statements
244
+ // no-bitwise
245
+ // no-plusplus
246
+
247
+ // Plugins
248
+ // eslint-plugin-react
249
+ "react/display-name": [2],
250
+ "react/jsx-boolean-value": [2, "always"],
251
+ "react/jsx-quotes": [2, "double"],
252
+ "react/jsx-no-undef": [2],
253
+ // "react/jsx-sort-props": [0], // TODO
254
+ "react/jsx-uses-react": [1],
255
+ "react/jsx-uses-vars": [1],
256
+ "react/no-did-mount-set-state": [2],
257
+ "react/no-did-update-set-state": [2],
258
+ // "react/no-multi-comp": [1], // TODO
259
+ "react/no-unknown-property": [2],
260
+ // "react/prop-types": [1], // TODO
261
+ "react/react-in-jsx-scope": [1],
262
+ "react/self-closing-comp": [2],
263
+ "react/wrap-multilines": [2]
264
+ }
265
+ }
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var babel = require('babel-core');
4
+
5
+ module.exports = {
6
+ process: function(src, filename) {
7
+ // Ignore files other than .js, .es, .jsx or .es6
8
+ if (!babel.canCompile(filename)) {
9
+ return '';
10
+ }
11
+
12
+ // Ignore all files within node_modules
13
+ if (filename.indexOf('node_modules') === -1) {
14
+ return babel.transform(src, {filename: filename}).code;
15
+ }
16
+
17
+ return src;
18
+ }
19
+ };
@@ -0,0 +1,124 @@
1
+ 'use strict';
2
+
3
+ var webpack = require('webpack'),
4
+ ExtractTextPlugin = require('extract-text-webpack-plugin');
5
+
6
+ /**
7
+ * Get configuration for Webpack
8
+ *
9
+ * @see http://webpack.github.io/docs/configuration
10
+ * https://github.com/petehunt/webpack-howto
11
+ *
12
+ * @param {boolean} release True if configuration is intended to be used in
13
+ * a release mode, false otherwise
14
+ * @return {object} Webpack configuration
15
+ */
16
+ module.exports = function(release) {
17
+ return {
18
+ entry: {
19
+ app: './src/app.js',
20
+ vendor: [
21
+ 'collections/sorted-set',
22
+ 'd3',
23
+ 'dagre',
24
+ 'dagre-d3',
25
+ 'event-source-polyfill',
26
+ 'fluxxor',
27
+ 'lodash',
28
+ 'moment',
29
+ 'react',
30
+ 'react-bootstrap',
31
+ 'react-router',
32
+ 'react-router-bootstrap',
33
+ 'superagent'
34
+ ]
35
+ },
36
+
37
+ output: {
38
+ filename: 'app.js',
39
+ path: './build/js/',
40
+ publicPath: '/js/'
41
+ },
42
+
43
+ cache: !release,
44
+ debug: !release,
45
+ devtool: 'source-map',
46
+
47
+ stats: {
48
+ colors: true,
49
+ reasons: !release
50
+ },
51
+
52
+ plugins: release ? [
53
+ new webpack.DefinePlugin({
54
+ 'process.env.NODE_ENV': '"production"',
55
+ '__DEV__': false
56
+ }),
57
+ new webpack.optimize.DedupePlugin(),
58
+ new webpack.optimize.UglifyJsPlugin(),
59
+ new webpack.optimize.OccurenceOrderPlugin(),
60
+ new webpack.optimize.AggressiveMergingPlugin(),
61
+ new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js'),
62
+ new ExtractTextPlugin('styles.css')
63
+ ] : [
64
+ new webpack.DefinePlugin({'__DEV__': true}),
65
+ new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js'),
66
+ new ExtractTextPlugin('styles.css')
67
+ ],
68
+
69
+ resolve: {
70
+ extensions: ['', '.webpack.js', '.web.js', '.js']
71
+ },
72
+
73
+ module: {
74
+ loaders: [
75
+ {
76
+ test: /\.less$/,
77
+ loader: ExtractTextPlugin.extract(
78
+ 'css-loader?sourceMap!autoprefixer-loader?{browsers:[' +
79
+ '"Android 2.3", "Android >= 4", "Chrome >= 20", "Firefox >= 24", ' +
80
+ '"Explorer >= 8", "iOS >= 6", "Opera >= 12", "Safari >= 6"]}!' +
81
+ 'less-loader?sourceMap'
82
+ )
83
+ },
84
+ {
85
+ test: /\.gif/,
86
+ loader: 'url-loader?limit=10000&mimetype=image/gif'
87
+ },
88
+ {
89
+ test: /\.jpg/,
90
+ loader: 'url-loader?limit=10000&mimetype=image/jpg'
91
+ },
92
+ {
93
+ test: /\.png/,
94
+ loader: 'url-loader?limit=10000&mimetype=image/png'
95
+ },
96
+ {
97
+ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
98
+ loader: 'file-loader?minetype=application/font-woff'
99
+ },
100
+ {
101
+ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
102
+ loader: 'file-loader?minetype=application/font-woff2'
103
+ },
104
+ {
105
+ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
106
+ loader: 'file-loader'
107
+ },
108
+ {
109
+ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
110
+ loader: 'file-loader'
111
+ },
112
+ {
113
+ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
114
+ loader: 'file-loader'
115
+ },
116
+ {
117
+ test: /\.js?$/,
118
+ exclude: /node_modules/,
119
+ loader: 'babel-loader?optional=runtime'
120
+ }
121
+ ]
122
+ }
123
+ };
124
+ };
@@ -0,0 +1,96 @@
1
+ 'use strict';
2
+
3
+ var g = require('gulp'),
4
+ p = require('gulp-load-plugins')(),
5
+ argv = require('minimist')(process.argv.slice(2)),
6
+ webpack = require('webpack'),
7
+ runSequence = require('run-sequence'),
8
+ del = require('del');
9
+
10
+ var RELEASE = !!argv.release,
11
+ watch = false,
12
+ paths = {
13
+ js: 'src/**/*.js',
14
+ images: 'src/images/*',
15
+ pages: 'src/pages/*.html'
16
+ };
17
+
18
+ var src = {};
19
+
20
+ g.task('clean', function(cb) {
21
+ return del(['build'], cb);
22
+ });
23
+
24
+ g.task('vendor', function() {
25
+ return g
26
+ .src('src/vendor/*.js')
27
+ .pipe(g.dest('build/js'))
28
+ .pipe(p.size({title: 'vendor'}));
29
+ });
30
+
31
+ g.task('bundle', function(cb) {
32
+ var started = false,
33
+ config = require('./config/webpack.js')(RELEASE),
34
+ bundler = webpack(config);
35
+
36
+ function bundle(err, stats) {
37
+ if (err) {
38
+ throw new p.util.PluginError('webpack', err);
39
+ }
40
+
41
+ var errors = stats.toJson({errorDetails: true}).errors;
42
+ if (errors.length > 0) {
43
+ p.util.log('[webpack]', errors[0]);
44
+ }
45
+ else {
46
+ p.util.log('bundle built');
47
+ }
48
+
49
+ if (argv.verbose) {
50
+ p.util.log('[webpack]', stats.toString({colors: true}));
51
+ }
52
+
53
+ if (!started) {
54
+ started = true;
55
+ return cb();
56
+ }
57
+
58
+ return false;
59
+ }
60
+
61
+ if (watch) {
62
+ bundler.watch(200, bundle);
63
+ } else {
64
+ bundler.run(bundle);
65
+ }
66
+ });
67
+
68
+ g.task('images', function() {
69
+ return g
70
+ .src(paths.images)
71
+ .pipe(g.dest('build/images'))
72
+ .pipe(p.size({title: 'images'}));
73
+ });
74
+
75
+ g.task('pages', function() {
76
+ return g
77
+ .src(paths.pages)
78
+ .pipe(g.dest('build'))
79
+ .pipe(p.size({title: 'pages'}));
80
+ });
81
+
82
+ g.task('watch', function(cb) {
83
+ watch = true;
84
+
85
+ runSequence('bundle');
86
+
87
+ cb();
88
+
89
+ console.log('Watching files for changes...');
90
+ });
91
+
92
+ g.task('build', function(cb) {
93
+ runSequence('clean', ['bundle', 'vendor', 'images', 'pages'], cb);
94
+ });
95
+
96
+ g.task('default', ['build']);