├── .gitignore
├── LICENSE
├── README.md
├── generators
├── app
│ ├── content
│ │ ├── .babelrc
│ │ ├── .eslintrc
│ │ ├── .flowconfig
│ │ ├── .gitignore
│ │ ├── .npmignore
│ │ ├── .sass-lint.yml
│ │ ├── LICENSE
│ │ ├── client
│ │ │ └── app
│ │ │ │ ├── app.config.js
│ │ │ │ ├── app.routes.js
│ │ │ │ ├── app.run.js
│ │ │ │ ├── app.scss
│ │ │ │ ├── dev.constants.js
│ │ │ │ ├── features
│ │ │ │ └── sample
│ │ │ │ │ ├── index.js
│ │ │ │ │ ├── sample.config.js
│ │ │ │ │ ├── sample.controller.js
│ │ │ │ │ ├── sample.routes.js
│ │ │ │ │ ├── sample.scss
│ │ │ │ │ ├── sample.service.js
│ │ │ │ │ ├── sample.spec.js
│ │ │ │ │ └── sample.tpl.html
│ │ │ │ ├── local.constants.js
│ │ │ │ └── prod.constants.js
│ │ ├── config
│ │ │ ├── webpack.config.build.js
│ │ │ ├── webpack.config.default.js
│ │ │ ├── webpack.config.module.js
│ │ │ ├── webpack.config.serve.js
│ │ │ ├── webpack.config.test.js
│ │ │ ├── webpack.make.js
│ │ │ └── webpack.tests.js
│ │ ├── index.js
│ │ ├── karma.conf.js
│ │ └── webpack.config.js
│ ├── index.js
│ └── templates
│ │ ├── _bower.json
│ │ ├── _index.html
│ │ ├── _package.json
│ │ └── client
│ │ └── app
│ │ └── _app.js
├── component
│ ├── index.js
│ └── templates
│ │ ├── _.scss
│ │ ├── _config.js
│ │ ├── _controller.js
│ │ ├── _directive.js
│ │ ├── _index.js
│ │ ├── _run.js
│ │ └── _tpl.html
└── feature
│ ├── index.js
│ └── templates
│ ├── _.scss
│ ├── _config.js
│ ├── _controller.js
│ ├── _index.js
│ ├── _routes.js
│ ├── _run.js
│ └── _tpl.html
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Compiled binary addons (http://nodejs.org/api/addons.html)
23 | build/Release
24 | dist/
25 |
26 | # Dependency directory
27 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
28 | node_modules
29 | bower_components
30 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Aleksander
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Angular-Webpack-Babel Generator
2 |
3 | [](https://david-dm.org/Foxandxss/angular-webpack-workflow#info=dependencies) [](https://david-dm.org/Foxandxss/angular-webpack-workflow#info=devDependencies)
4 |
5 | This generator is Heavily inspired by [Foxandxss's angular-webpack-workflow](https://github.com/Foxandxss/angular-webpack-workflow) - he is to have all the credit. I merely needed a generator for a few internal projects - and I tweaked it to suit my particular needs and requirements.
6 |
7 | Since Foxandxss passes on all credit to Cesar Andreau, I respectfully do the same.
8 | Taken from Foxandxss original README:
9 | > It is a direct port of the amazing [react workflow](https://github.com/cesarandreu/web-app) of [Cesar Andreu](https://github.com/cesarandreu). All the credits goes for him.
10 |
11 |
12 | ## Features
13 |
14 | * Heavily commented webpack configuration with reasonable
15 | * ES6, and ES7 support with babel.js.
16 | * Source maps included in all builds.
17 | * Development server with live reload.
18 | * Browsersync for easy mobile testing
19 | * Production builds with cache busting and asset minification.
20 | * Testing environment using karma to run tests and jasmine as the framework.
21 | * Code coverage when tests are run.
22 | * No gulp and no grunt, just npm run-scripts.
23 | * Flowtype enabled
24 | * Suggested application structure
25 | * Generator for both app wide features and components
26 |
27 |
28 | ## Installation
29 |
30 | ### Requirements
31 | The project also requires a MINIMUM of node v. 0.12.0. I recommend installing the latest version.
32 | First of all, make sure you have installed all the requirements to run the project:
33 |
34 | Install ``yo``, ``grunt-cli``, ``webpack``, ``karma``, ``eslint``, ``babel-eslint``
35 | ```shell
36 | npm install -g yo grunt-cli webpack karma eslint babel-eslint
37 | ```
38 |
39 | Install the ``generator-angular-webpack-starter``:
40 | ```shell
41 | npm install -g generator-angular-webpack-starter
42 | ```
43 |
44 | ### Usage
45 | Make a new directory and ``cd``into it:
46 | ```shell
47 | mkdir my-new-directory && cd $_
48 | ```
49 |
50 | Run ``yo angular-webpack-starter``:
51 | ```shell
52 | yo angular-webpack-starter
53 | ```
54 |
55 | ### Scripts
56 |
57 | All scripts are run with `npm run [script]`, for example: `npm run test`.
58 |
59 | * `build` - will run both build:module and build:dist
60 | * `build:dist` - will build and minify the app to the dist folder with dependencies,
61 | * `build:module`- will build and minify the app to the lib folder. This is for usage as a module in other applications. Without dependencies.
62 | * `serve` - start development server with local configuration, try it by opening `http://localhost:8080/` or the browserSync version at `http://localhost:3000/``
63 | * `serve:dev` - development server with development configuration
64 | * `serve:prod`- development server with production configuration
65 | * `test` - run all tests
66 | * `test:live` - continuously run unit tests watching for changes
67 |
68 | See what each script does by looking at the `scripts` section in [package.json](./package.json).
69 |
70 | Local, Develop and Production configuration can be configured in the following files in `client/app/`:
71 | ```
72 | local.constants.js
73 | dev.constants.js
74 | prod.constants.js
75 | ```
76 | Webpack will automatically know which one to use based on the serve parameter provided.
77 | ### Sub-generators
78 | * [angular-webpack-starter:feature]
79 | * [angular-webpack-starter:component]
80 |
81 | #### Feature
82 | Will generate a new feature within a folder from the directory that you are currently in:
83 | ```shell
84 | yo angular-webpack-starter:feature featureName
85 | ```
86 |
87 | To include the feature in the application, simply add the following to your app.js
88 | and include it in the module:
89 | ```javascript
90 | import featureName from './features/featureName';
91 |
92 | angular.module('app', [uirouter, featureName])
93 | .config(config)
94 | .config(routes)
95 | .run(run);
96 | ```
97 |
98 | you can test the feature by trying to navigate to: http://localhost:3000/#/featureName
99 |
100 | #### Component
101 | Will generate a new component within a folder from the directory that you are currently in:
102 | ```shell
103 | yo angular-webpack-starter:component componentName
104 | ```
105 |
106 | To include the component in the application, simply add the following to your app.js or one of your features and include it in its module and include it in the module:
107 | ```javascript
108 | import componentName from './components/componentName';
109 |
110 | angular.module('app', [uirouter, componentName])
111 | .config(config)
112 | .config(routes)
113 | .run(run);
114 | ```
115 |
116 | Note that to keep app.js as lean as possible it is recommended to only import features in the modules that depend on them.
117 |
118 | You can test the component by adding the following to one of your incorporating features tpl.html files:
119 | ```html
120 |
121 | ```
122 |
123 | ## Extra tools
124 |
125 | ### [ESLint](http://eslint.org/)
126 | ESLint is integrated in the project and is configurable through the .eslintrc
127 | file. All rules have been disabled by default.
128 | To enforce and automatically fix ESLint rules, enable fix in the eslint settings in config/webpack.make.js file. It is disabled by default.
129 |
130 | ```javascript
131 | /**
132 | * use the .eslint config
133 | * optionally enable autofix to force rules
134 | */
135 | config.eslint = {
136 | configFile: '.eslintrc',
137 | fix: true
138 | }
139 | ```
140 |
141 | ### [Flow](http://flowtype.org/)
142 | Flow has also been integrated in the project. It is completely optional, but will enable editors to intelligently warn you about errors and offer auto completion on flow documented functions and classes. Read more about how to set it up on the official flow page [here](http://flowtype.org/)
143 |
144 |
145 | ## Example and tutorial
146 | Foxandxss has provided some excellent material on how to write Angular with ES6, which I have mostly strived to adhere to in the generator.
147 |
148 | It's generally a good introctory read: [angular-tips](http://angular-tips.com/blog/2015/06/using-angular-1-dot-x-with-es6-and-webpack/)
149 |
150 | ## License
151 |
152 | The license of this workflow is MIT.
153 |
--------------------------------------------------------------------------------
/generators/app/content/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015", "stage-0"],
3 | "plugins": ["syntax-flow","transform-flow-strip-types"]
4 | }
5 |
--------------------------------------------------------------------------------
/generators/app/content/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "babel-eslint",
3 | "rules": {
4 | ////////// Possible Errors //////////
5 |
6 | "no-comma-dangle": 0, // disallow trailing commas in object literals
7 | "no-cond-assign": 0, // disallow assignment in conditional expressions
8 | "no-console": 0, // disallow use of console (off by default in the node environment)
9 | "no-constant-condition": 0, // disallow use of constant expressions in conditions
10 | "no-control-regex": 0, // disallow control characters in regular expressions
11 | "no-debugger": 0, // disallow use of debugger
12 | "no-dupe-keys": 0, // disallow duplicate keys when creating object literals
13 | "no-empty": 0, // disallow empty statements
14 | "no-empty-class": 0, // disallow the use of empty character classes in regular expressions
15 | "no-ex-assign": 0, // disallow assigning to the exception in a catch block
16 | "no-extra-boolean-cast": 0, // disallow double-negation boolean casts in a boolean context
17 | "no-extra-parens": 0, // disallow unnecessary parentheses (off by default)
18 | "no-extra-semi": 0, // disallow unnecessary semicolons
19 | "no-func-assign": 0, // disallow overwriting functions written as function declarations
20 | "no-inner-declarations": 0, // disallow function or variable declarations in nested blocks
21 | "no-invalid-regexp": 0, // disallow invalid regular expression strings in the RegExp constructor
22 | "no-irregular-whitespace": 0, // disallow irregular whitespace outside of strings and comments
23 | "no-negated-in-lhs": 0, // disallow negation of the left operand of an in expression
24 | "no-obj-calls": 0, // disallow the use of object properties of the global object (Math and JSON) as functions
25 | "no-regex-spaces": 0, // disallow multiple spaces in a regular expression literal
26 | "no-reserved-keys": 0, // disallow reserved words being used as object literal keys (off by default)
27 | "no-sparse-arrays": 0, // disallow sparse arrays
28 | "no-unreachable": 0, // disallow unreachable statements after a return, throw, continue, or break statement
29 | "use-isnan": 0, // disallow comparisons with the value NaN
30 | "valid-jsdoc": 0, // Ensure JSDoc comments are valid (off by default)
31 | "valid-typeof": 0, // Ensure that the results of typeof are compared against a valid string
32 |
33 |
34 | ////////// Best Practices //////////
35 |
36 | "block-scoped-var": 0, // treat var statements as if they were block scoped (off by default)
37 | "complexity": 0, // specify the maximum cyclomatic complexity allowed in a program (off by default)
38 | "consistent-return": 0, // require return statements to either always or never specify values
39 | "curly": 0, // specify curly brace conventions for all control statements
40 | "default-case": 0, // require default case in switch statements (off by default)
41 | "dot-notation": 0, // encourages use of dot notation whenever possible
42 | "eqeqeq": 0, // require the use of === and !==
43 | "guard-for-in": 0, // make sure for-in loops have an if statement (off by default)
44 | "no-alert": 0, // disallow the use of alert, confirm, and prompt
45 | "no-caller": 0, // disallow use of arguments.caller or arguments.callee
46 | "no-div-regex": 0, // disallow division operators explicitly at beginning of regular expression (off by default)
47 | "no-else-return": 0, // disallow else after a return in an if (off by default)
48 | "no-empty-label": 0, // disallow use of labels for anything other then loops and switches
49 | "no-eq-null": 0, // disallow comparisons to null without a type-checking operator (off by default)
50 | "no-eval": 0, // disallow use of eval()
51 | "no-extend-native": 0, // disallow adding to native types
52 | "no-extra-bind": 0, // disallow unnecessary function binding
53 | "no-fallthrough": 0, // disallow fallthrough of case statements
54 | "no-floating-decimal": 0, // disallow the use of leading or trailing decimal points in numeric literals (off by default)
55 | "no-implied-eval": 0, // disallow use of eval()-like methods
56 | "no-iterator": 0, // disallow usage of __iterator__ property
57 | "no-labels": 0, // disallow use of labeled statements
58 | "no-lone-blocks": 0, // disallow unnecessary nested blocks
59 | "no-loop-func": 0, // disallow creation of functions within loops
60 | "no-multi-spaces": 0, // disallow use of multiple spaces
61 | "no-multi-str": 0, // disallow use of multiline strings
62 | "no-native-reassign": 0, // disallow reassignments of native objects
63 | "no-new": 0, // disallow use of new operator when not part of the assignment or comparison
64 | "no-new-func": 0, // disallow use of new operator for Function object
65 | "no-new-wrappers": 0, // disallows creating new instances of String, Number, and Boolean
66 | "no-octal": 0, // disallow use of octal literals
67 | "no-octal-escape": 0, // disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251";
68 | "no-process-env": 0, // disallow use of process.env (off by default)
69 | "no-proto": 0, // disallow usage of __proto__ property
70 | "no-redeclare": 0, // disallow declaring the same variable more then once
71 | "no-return-assign": 0, // disallow use of assignment in return statement
72 | "no-script-url": 0, // disallow use of javascript: urls.
73 | "no-self-compare": 0, // disallow comparisons where both sides are exactly the same (off by default)
74 | "no-sequences": 0, // disallow use of comma operator
75 | "no-unused-expressions": 0, // disallow usage of expressions in statement position
76 | "no-void": 0, // disallow use of void operator (off by default)
77 | "no-warning-comments": 0, // disallow usage of configurable warning terms in comments, e.g. TODO or FIXME (off by default)
78 | "no-with": 0, // disallow use of the with statement
79 | "radix": 0, // require use of the second argument for parseInt() (off by default)
80 | "vars-on-top": 0, // requires to declare all vars on top of their containing scope (off by default)
81 | "wrap-iife": 0, // require immediate function invocation to be wrapped in parentheses (off by default)
82 | "yoda": 0, // require or disallow Yoda conditions
83 |
84 |
85 | ////////// Strict Mode //////////
86 |
87 | "global-strict": 0, // (deprecated) require or disallow the "use strict" pragma in the global scope (off by default in the node environment)
88 | "no-extra-strict": 0, // (deprecated) disallow unnecessary use of "use strict"; when already in strict mode
89 | "strict": 0, // controls location of Use Strict Directives
90 |
91 |
92 | ////////// Variables //////////
93 |
94 | "no-catch-shadow": 0, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment)
95 | "no-delete-var": 0, // disallow deletion of variables
96 | "no-label-var": 0, // disallow labels that share a name with a variable
97 | "no-shadow": 0, // disallow declaration of variables already declared in the outer scope
98 | "no-shadow-restricted-names": 0, // disallow shadowing of names such as arguments
99 | "no-undef": 0, // disallow use of undeclared variables unless mentioned in a /*global */ block
100 | "no-undef-init": 0, // disallow use of undefined when initializing variables
101 | "no-undefined": 0, // disallow use of undefined variable (off by default)
102 | "no-unused-vars": 0, // disallow declaration of variables that are not used in the code
103 | "no-use-before-define": 0, // disallow use of variables before they are defined
104 |
105 |
106 | ////////// Node.js //////////
107 |
108 | "handle-callback-err": 0, // enforces error handling in callbacks (off by default) (on by default in the node environment)
109 | "no-mixed-requires": 0, // disallow mixing regular variable and require declarations (off by default) (on by default in the node environment)
110 | "no-new-require": 0, // disallow use of new operator with the require function (off by default) (on by default in the node environment)
111 | "no-path-concat": 0, // disallow string concatenation with __dirname and __filename (off by default) (on by default in the node environment)
112 | "no-process-exit": 0, // disallow process.exit() (on by default in the node environment)
113 | "no-restricted-modules": 0, // restrict usage of specified node modules (off by default)
114 | "no-sync": 0, // disallow use of synchronous methods (off by default)
115 |
116 |
117 | ////////// Stylistic Issues //////////
118 |
119 | "brace-style": 0, // enforce one true brace style (off by default)
120 | "camelcase": 1, // require camel case names
121 | "comma-spacing": 0, // enforce spacing before and after comma
122 | "comma-style": 0, // enforce one true comma style (off by default)
123 | "consistent-this": 0, // enforces consistent naming when capturing the current execution context (off by default)
124 | "eol-last": 0, // enforce newline at the end of file, with no multiple empty lines
125 | "func-names": 0, // require function expressions to have a name (off by default)
126 | "func-style": 0, // enforces use of function declarations or expressions (off by default)
127 | "key-spacing": 0, // enforces spacing between keys and values in object literal properties
128 | "max-nested-callbacks": 0, // specify the maximum depth callbacks can be nested (off by default)
129 | "new-cap": 0, // require a capital letter for constructors
130 | "new-parens": 0, // disallow the omission of parentheses when invoking a constructor with no arguments
131 | "no-array-constructor": 0, // disallow use of the Array constructor
132 | "no-inline-comments": 0, // disallow comments inline after code (off by default)
133 | "no-lonely-if": 0, // disallow if as the only statement in an else block (off by default)
134 | "no-mixed-spaces-and-tabs": 0, // disallow mixed spaces and tabs for indentation
135 | "no-multiple-empty-lines": 0, // disallow multiple empty lines (off by default)
136 | "no-nested-ternary": 0, // disallow nested ternary expressions (off by default)
137 | "no-new-object": 0, // disallow use of the Object constructor
138 | "no-space-before-semi": 0, // disallow space before semicolon
139 | "no-spaced-func": 0, // disallow space between function identifier and application
140 | "no-ternary": 0, // disallow the use of ternary operators (off by default)
141 | "no-trailing-spaces": 0, // disallow trailing whitespace at the end of lines
142 | "no-underscore-dangle": 0, // disallow dangling underscores in identifiers
143 | "no-wrap-func": 0, // disallow wrapping of non-IIFE statements in parens
144 | "one-var": 0, // allow just one var statement per function (off by default)
145 | "operator-assignment": 0, // require assignment operator shorthand where possible or prohibit it entirely (off by default)
146 | "padded-blocks": 0, // enforce padding within blocks (off by default)
147 | "quote-props": 0, // require quotes around object literal property names (off by default)
148 | "quotes": 0, // specify whether double or single quotes should be used
149 | "semi": 0, // require or disallow use of semicolons instead of ASI
150 | "sort-vars": 0, // sort variables within the same declaration block (off by default)
151 | "space-after-function-name": 0, // require a space after function names (off by default)
152 | "space-after-keywords": 0, // require a space after certain keywords (off by default)
153 | "space-before-blocks": 0, // require or disallow space before blocks (off by default)
154 | "space-in-brackets": 0, // require or disallow spaces inside brackets (off by default)
155 | "space-in-parens": 0, // require or disallow spaces inside parentheses (off by default)
156 | "space-infix-ops": 0, // require spaces around operators
157 | "space-return-throw-case": 0, // require a space after return, throw, and case
158 | "space-unary-ops": 0, // Require or disallow spaces before/after unary operators (words on by default, nonwords off by default)
159 | "spaced-line-comment": 0, // require or disallow a space immediately following the // in a line comment (off by default)
160 | "wrap-regex": 0, // require regex literals to be wrapped in parentheses (off by default)
161 |
162 |
163 | ////////// ECMAScript 6 //////////
164 |
165 | "no-var": 0, // require let or const instead of var (off by default)
166 | "generator-star": 0, // enforce the position of the * in generator functions (off by default)
167 |
168 |
169 | ////////// Legacy //////////
170 |
171 | "max-depth": 0, // specify the maximum depth that blocks can be nested (off by default)
172 | "max-len": 0, // specify the maximum length of a line in your program (off by default)
173 | "max-params": 0, // limits the number of parameters that can be used in the function declaration. (off by default)
174 | "max-statements": 0, // specify the maximum number of statement allowed in a function (off by default)
175 | "no-bitwise": 0, // disallow use of bitwise operators (off by default)
176 | "no-plusplus": 0 // disallow use of unary operators, ++ and -- (off by default)
177 | }
178 | }
179 |
--------------------------------------------------------------------------------
/generators/app/content/.flowconfig:
--------------------------------------------------------------------------------
1 | [ignore]
2 |
3 | [include]
4 |
5 | [libs]
6 |
7 | [options]
8 |
--------------------------------------------------------------------------------
/generators/app/content/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Compiled binary addons (http://nodejs.org/api/addons.html)
23 | build/Release
24 | dist
25 | lib
26 | test
27 |
28 | # Dependency directory
29 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
30 | node_modules
31 | bower_components
32 |
--------------------------------------------------------------------------------
/generators/app/content/.npmignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Compiled binary addons (http://nodejs.org/api/addons.html)
23 | build/Release
24 |
25 | # Dependency directory
26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
27 | node_modules
28 | bower_components
29 |
--------------------------------------------------------------------------------
/generators/app/content/.sass-lint.yml:
--------------------------------------------------------------------------------
1 | options:
2 | formatter: stylish
3 | files:
4 | include: '**/*.s+(a|c)ss'
5 | rules:
6 | # Extends
7 | extends-before-mixins: 1
8 | extends-before-declarations: 1
9 | placeholder-in-extend: 1
10 |
11 | # Mixins
12 | mixins-before-declarations: 1
13 |
14 | # Line Spacing
15 | one-declaration-per-line: 1
16 | empty-line-between-blocks: 1
17 | single-line-per-selector: 1
18 |
19 | # Disallows
20 | no-color-keywords: 1
21 | no-color-literals: 1
22 | no-css-comments: 1
23 | no-debug: 1
24 | no-duplicate-properties: 1
25 | no-empty-rulesets: 1
26 | no-extends: 0
27 | no-ids: 1
28 | no-important: 1
29 | no-invalid-hex: 1
30 | no-mergeable-selectors: 1
31 | no-misspelled-properties: 1
32 | no-qualifying-elements: 1
33 | no-trailing-zero: 1
34 | no-transition-all: 1
35 | no-url-protocols: 1
36 | no-vendor-prefixes: 1
37 | no-warn: 1
38 |
39 | # Nesting
40 | force-attribute-nesting: 1
41 | force-element-nesting: 1
42 | force-pseudo-nesting: 1
43 |
44 | # Name Formats
45 | function-name-format: 1
46 | mixin-name-format: 1
47 | placeholder-name-format: 1
48 | variable-name-format: 1
49 |
50 | # Style Guide
51 | border-zero: 1
52 | brace-style: 1
53 | clean-import-paths: 1
54 | empty-args: 1
55 | hex-length: 1
56 | hex-notation: 1
57 | indentation: 1
58 | leading-zero: 1
59 | nesting-depth: 1
60 | property-sort-order: 1
61 | quotes: 1
62 | shorthand-values: 1
63 | url-quotes: 1
64 | variable-for-property: 1
65 | zero-unit: 1
66 |
67 | # Inner Spacing
68 | space-after-comma: 1
69 | space-before-colon: 1
70 | space-after-colon: 1
71 | space-before-brace: 1
72 | space-before-bang: 1
73 | space-after-bang: 1
74 | space-between-parens: 1
75 |
76 | # Final Items
77 | trailing-semicolon: 1
78 | final-newline: 1
79 |
--------------------------------------------------------------------------------
/generators/app/content/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Aleksander
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/generators/app/content/client/app/app.config.js:
--------------------------------------------------------------------------------
1 | /* @ngInject */
2 | export default function config(){
3 | console.log("Config loaded")
4 | }
5 |
--------------------------------------------------------------------------------
/generators/app/content/client/app/app.routes.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | /* @ngInject */
4 | export default function routes($urlRouterProvider){
5 | $urlRouterProvider.otherwise('/sample');
6 | }
7 |
--------------------------------------------------------------------------------
/generators/app/content/client/app/app.run.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | /**
4 | * Specify any dependencies here. Alternatively shift to ngAnnotate
5 | * @type {string}
6 | */
7 | run.$inject = []
8 |
9 | /* @ngInject */
10 | export default function run(){
11 | console.log("Run loaded")
12 | }
13 |
--------------------------------------------------------------------------------
/generators/app/content/client/app/app.scss:
--------------------------------------------------------------------------------
1 | $main-color: #fff;
2 |
3 | .test-class {
4 | color: $main-color;
5 | }
6 |
7 |
8 | @import 'features/sample/sample';
9 |
--------------------------------------------------------------------------------
/generators/app/content/client/app/dev.constants.js:
--------------------------------------------------------------------------------
1 | export default {
2 | env: "development"
3 | }
4 |
--------------------------------------------------------------------------------
/generators/app/content/client/app/features/sample/index.js:
--------------------------------------------------------------------------------
1 | import angular from 'angular';
2 | import uirouter from 'angular-ui-router';
3 |
4 | // Import base modules
5 | import config from './sample.config';
6 | import routes from './sample.routes';
7 | import controller from './sample.controller';
8 | import service from './sample.service';
9 |
10 | // Import internal modules
11 |
12 |
13 | export default angular.module('app.sample', [uirouter])
14 | .config(config)
15 | .config(routes)
16 | .controller(controller.UID, controller)
17 | .service(service.UID(), service)
18 | .name;
19 |
--------------------------------------------------------------------------------
/generators/app/content/client/app/features/sample/sample.config.js:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * Run function for something
4 | * @param $stateProvider [description]
5 | */
6 | /* @ngInject */
7 | export default function config() {
8 | }
9 |
--------------------------------------------------------------------------------
/generators/app/content/client/app/features/sample/sample.controller.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This i a SampleController
3 | * This file is deliberately not using flowtype, to showcase how
4 | * an ES6 class is normally assigned
5 | */
6 | export default class SampleController {
7 |
8 | /**
9 | * Static getter, that returns the unique identifier of the class. Used for registration with modules.
10 | */
11 | static get UID(){
12 | return "SampleController"
13 | }
14 |
15 | /* @ngInject */
16 | constructor(SampleService) {
17 | // Properties of the class are defined in the constructor with this
18 | this.greeting = SampleService.generateGreeting();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/generators/app/content/client/app/features/sample/sample.routes.js:
--------------------------------------------------------------------------------
1 |
2 | import controller from './sample.controller'
3 |
4 | /**
5 | * Routing function for sample
6 | * @param $stateProvider
7 | */
8 | /* @ngInject */
9 | export default function routes($stateProvider) {
10 | $stateProvider.state("sample", {
11 | url: "/sample",
12 | template: require("./sample.tpl.html"),
13 | controller: controller.UID,
14 | controllerAs: "sample"
15 | });
16 | }
17 |
--------------------------------------------------------------------------------
/generators/app/content/client/app/features/sample/sample.scss:
--------------------------------------------------------------------------------
1 |
2 | $sample-color: #5c5c06;
3 |
4 | .sample-class {
5 | color: $sample-color;
6 | }
7 |
--------------------------------------------------------------------------------
/generators/app/content/client/app/features/sample/sample.service.js:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | /* @flow */
5 |
6 | /**
7 | * Example service intended to show how to use services
8 | * Flowtype has been enabled for this file to showcase it's use.
9 | *
10 | */
11 | export default class SampleService {
12 | // Define a unique identifier for the SampleService to avoid typo's when including it.
13 | static UID(): string{
14 | return "SampleService"
15 | }
16 |
17 | // With flowtype class variables can be defined with type.
18 | greeting: string;
19 |
20 | /* @ngInject */
21 | constructor() {
22 | /// Service properties are defined in the constructor with this.
23 | this.greeting = "Welcome to the sample";
24 |
25 | /// with flowtype enabled the following statement will result in an error
26 | //this.greeting = 2
27 | }
28 |
29 | /**
30 | * Example function to demonstrate how to use services
31 | * With flowtype the return type can be defined.
32 | * @return {[type]}
33 | */
34 | generateGreeting(): string{
35 | return this.greeting;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/generators/app/content/client/app/features/sample/sample.spec.js:
--------------------------------------------------------------------------------
1 | describe("A suite", function() {
2 | it("contains spec with an expectation", function() {
3 | expect(true).toBe(true);
4 | });
5 | it("contains spec with another expectation", () => {
6 | expect(true).toBe(true);
7 | })
8 | });
9 |
--------------------------------------------------------------------------------
/generators/app/content/client/app/features/sample/sample.tpl.html:
--------------------------------------------------------------------------------
1 |
2 | {{sample.greeting}}
3 |
4 |
--------------------------------------------------------------------------------
/generators/app/content/client/app/local.constants.js:
--------------------------------------------------------------------------------
1 | export default {
2 | env: "local"
3 | }
4 |
--------------------------------------------------------------------------------
/generators/app/content/client/app/prod.constants.js:
--------------------------------------------------------------------------------
1 | export default {
2 | env: "production"
3 | }
4 |
--------------------------------------------------------------------------------
/generators/app/content/config/webpack.config.build.js:
--------------------------------------------------------------------------------
1 | var webpack = require('webpack');
2 | var path = require("path");
3 | var ExtractTextPlugin = require('extract-text-webpack-plugin');
4 |
5 | module.exports = function(ENV) {
6 | return {
7 | /**
8 | * Entry
9 | * Reference: http://webpack.github.io/docs/configuration.html#entry
10 | * Should be an empty object if it's generating a test build
11 | * Karma will set this when it's a test build
12 | */
13 | //context: path.resolve(__dirname),
14 | /**
15 | * Output
16 | * Reference: http://console.github.io/docs/configuration.html#output
17 | * Should be an empty object if it's generating a test build
18 | * Karma will handle setting it up for you when it's a test build
19 | */
20 | output: {
21 | // Absolute output directory
22 | path: __dirname + '/../dist',
23 | publicPath: '/',
24 | filename: '[name].bundle.js',
25 | chunkFilename: '[name].bundle.js',
26 | libraryTarget: 'umd',
27 | library: '[name]'
28 | },
29 | /**
30 | * Devtool settings
31 | * Reference: http://webpack.github.io/docs/configuration.html#devtool
32 | */
33 | devtool: 'source-map',
34 | /**
35 | * Plugins
36 | * Reference: http://webpack.github.io/docs/configuration.html#plugins
37 | * List: http://webpack.github.io/docs/list-of-plugins.html
38 | */
39 | plugins: [
40 |
41 | // Reference: http://webpack.github.io/docs/list-of-plugins.html#noerrorsplugin
42 | // Only emit files when there are no errors
43 | new webpack.NoErrorsPlugin(),
44 |
45 | // Reference: http://webpack.github.io/docs/list-of-plugins.html#dedupeplugin
46 | // Dedupe modules in the output
47 | new webpack.optimize.DedupePlugin(),
48 | ]
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/generators/app/content/config/webpack.config.default.js:
--------------------------------------------------------------------------------
1 | var autoprefixer = require('autoprefixer');
2 | var webpack = require('webpack');
3 | var path = require("path");
4 | var HtmlWebpackPlugin = require('html-webpack-plugin');
5 | var ExtractTextPlugin = require('extract-text-webpack-plugin');
6 | var ngAnnotatePlugin = require('ng-annotate-webpack-plugin');
7 |
8 | module.exports = function(ENV, options) {
9 | return {
10 | /**
11 | * Resolve
12 | * Make bower_components available for the resolvers
13 | */
14 | resolve: {
15 | root: [path.join(__dirname, "./bower_components")],
16 | alias: {
17 | appConstants: "./" + ENV + ".constants.js"
18 | }
19 | },
20 | /**
21 | * Entry
22 | * Reference: http://webpack.github.io/docs/configuration.html#entry
23 | * Should be an empty object if it's generating a test build
24 | * Karma will set this when it's a test build
25 | */
26 | entry: {
27 | app: './client/app/app.js'
28 | },
29 | /**
30 | * ESLint
31 | * use the .eslint config
32 | * optionally enable autofix to force rules
33 | */
34 | eslint: {
35 | configFile: '.eslintrc',
36 | //fix: true
37 | },
38 | /**
39 | * Output
40 | * Reference: http://console.github.io/docs/configuration.html#output
41 | * Should be an empty object if it's generating a test build
42 | * Karma will handle setting it up for you when it's a test build
43 | */
44 | output: {
45 | // Absolute output directory
46 | path: __dirname + '/../dist',
47 | publicPath: 'http://localhost:' + options.devServerPort+"/",
48 | filename: '[name].bundle.js',
49 | chunkFilename: '[name].bundle.js'
50 | },
51 | /**
52 | * Devtool settings
53 | * Reference: http://webpack.github.io/docs/configuration.html#devtool
54 | */
55 | devtool: '#eval-module-source-map',
56 | /**
57 | * PostCSS
58 | * Reference: https://github.com/postcss/autoprefixer-core
59 | * Add vendor prefixes to your css
60 | */
61 | postcss: [
62 | autoprefixer({
63 | browsers: ['last 2 version']
64 | })
65 | ],
66 | /**
67 | * Dev server configuration
68 | * Reference: http://webpack.github.io/docs/configuration.html#devserver
69 | * Reference: http://webpack.github.io/docs/webpack-dev-server.html
70 | */
71 | devServer: {
72 | contentBase: '../dist',
73 | stats: {
74 | modules: false,
75 | cached: false,
76 | colors: true,
77 | chunk: true,
78 | inline: true,
79 | progres: true,
80 | hot: true
81 | },
82 | port: options.devServerPort
83 | },
84 | /**
85 | * Loaders
86 | * Reference: http://webpack.github.io/docs/configuration.html#module-loaders
87 | * List: http://webpack.github.io/docs/list-of-loaders.html
88 | * This handles most of the magic responsible for converting modules
89 | */
90 | module: {
91 | preloaders: [],
92 | loaders: [{
93 | // JS LOADER
94 | // Reference: https://github.com/babel/babel-loader
95 | test: /\.(js|jsx)$/,
96 | loader: 'babel',
97 | exclude: [/node_modules/, /bower_components/]
98 | },
99 | {
100 | // ASSET LOADER
101 | // Reference: https://github.com/webpack/file-loader
102 | // Copy png, jpg, jpeg, gif, svg, woff, woff2, ttf, eot files to output
103 | // Rename the file using the asset hash
104 | // Pass along the updated reference to your code
105 | // You can add here any file extension you want to get copied to your output
106 | test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/,
107 | loader: "file-loader?name=[name].[ext]"
108 | }, {
109 | // HTML LOADER
110 | // Reference: https://github.com/webpack/raw-loader
111 | // Allow loading html through js
112 | test: /\.html$/,
113 | loader: 'raw'
114 | },
115 | {
116 | test: /\.css$/,
117 | // Reference: https://github.com/webpack/extract-text-webpack-plugin
118 | // Extract css files in production builds
119 | //
120 | // Reference: https://github.com/webpack/style-loader
121 | // Use style-loader in development for hot-loading
122 | loader: ExtractTextPlugin.extract('style',
123 | 'css?sourceMap!postcss')
124 | },
125 | {
126 | // Sass Loader
127 | test: /\.scss$/,
128 | loaders: ["style", "css", "sass"]
129 | },
130 | {
131 | // ESLint loader
132 | test: /\.js$/,
133 | loader: "eslint-loader",
134 | exclude: [/node_modules/, /bower_components/]
135 | }]
136 | },
137 | /**
138 | * Plugins
139 | * Reference: http://webpack.github.io/docs/configuration.html#plugins
140 | * List: http://webpack.github.io/docs/list-of-plugins.html
141 | */
142 | plugins: [
143 |
144 | // Reference: https://github.com/webpack/extract-text-webpack-plugin
145 | // Extract css files
146 | // Disabled when in test mode or not in build mode
147 | new ExtractTextPlugin('[name].css', {
148 | }),
149 | new ngAnnotatePlugin({
150 | add: true,
151 | // other ng-annotate options here
152 | }),
153 | new webpack.ResolverPlugin(
154 | new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin(
155 | "../bower.json", ["main"])
156 | ),
157 | new HtmlWebpackPlugin({
158 | template:'./client/index.html',
159 | inject: 'body'
160 | })
161 | ]
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/generators/app/content/config/webpack.config.module.js:
--------------------------------------------------------------------------------
1 | var webpack = require('webpack');
2 | var path = require("path");
3 | var ExtractTextPlugin = require('extract-text-webpack-plugin');
4 | var fs = require('fs');
5 |
6 | var nodeModules = {};
7 | fs.readdirSync('node_modules')
8 | .filter(function(x) {
9 | return ['.bin'].indexOf(x) === -1;
10 | }).forEach(function(mod) {
11 | nodeModules[mod] = 'commonjs ' + mod;
12 | });
13 |
14 | module.exports = function(ENV) {
15 | return {
16 | /**
17 | * Entry
18 | * Reference: http://webpack.github.io/docs/configuration.html#entry
19 | * Should be an empty object if it's generating a test build
20 | * Karma will set this when it's a test build
21 | */
22 | entry : './index.js' ,
23 | //context: path.resolve(__dirname),
24 | //resolve: {
25 | // root: path.resolve(__dirname)
26 | // },
27 | //context: path.resolve(__dirname),
28 | /**
29 | * Output
30 | * Reference: http://console.github.io/docs/configuration.html#output
31 | * Should be an empty object if it's generating a test build
32 | * Karma will handle setting it up for you when it's a test build
33 | */
34 | output: {
35 | // Absolute output directory
36 | path: __dirname + '/../lib',
37 | filename: 'index.js',
38 | libraryTarget: 'umd',
39 | library: '[name]'
40 | },
41 |
42 | externals: {
43 | angular: "angular"
44 | },
45 | /**
46 | * Plugins
47 | * Reference: http://webpack.github.io/docs/configuration.html#plugins
48 | * List: http://webpack.github.io/docs/list-of-plugins.html
49 | */
50 | plugins: [
51 |
52 | // Reference: http://webpack.github.io/docs/list-of-plugins.html#noerrorsplugin
53 | // Only emit files when there are no errors
54 | new webpack.NoErrorsPlugin(),
55 |
56 | // Reference: http://webpack.github.io/docs/list-of-plugins.html#dedupeplugin
57 | // Dedupe modules in the output
58 | new webpack.optimize.DedupePlugin()
59 | ]
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/generators/app/content/config/webpack.config.serve.js:
--------------------------------------------------------------------------------
1 | var BrowserSyncPlugin = require('browser-sync-webpack-plugin');
2 | var path = require("path");
3 |
4 | module.exports = function(ENV, options) {
5 | return {
6 | plugins : [
7 | new BrowserSyncPlugin(
8 | // BrowserSync options
9 | {
10 | // browse to http://localhost:3000/ during development
11 | host: 'localhost',
12 | port: 3000,
13 | // proxy the Webpack Dev Server endpoint
14 | // (which should be serving on http://localhost:3100/)
15 | // through BrowserSync
16 | proxy: 'http://localhost:'+options.devServerPort
17 | },
18 | // plugin options
19 | {
20 | // prevent BrowserSync from reloading the page
21 | // and let Webpack Dev Server take care of this
22 | reload: false
23 | }
24 | )
25 | ]
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/generators/app/content/config/webpack.config.test.js:
--------------------------------------------------------------------------------
1 | var autoprefixer = require('autoprefixer');
2 | var webpack = require('webpack');
3 | var path = require("path");
4 | var HtmlWebpackPlugin = require('html-webpack-plugin');
5 | var ExtractTextPlugin = require('extract-text-webpack-plugin');
6 | var ngAnnotatePlugin = require('ng-annotate-webpack-plugin');
7 |
8 | module.exports = function(ENV, options) {
9 | return {
10 | /**
11 | * Resolve
12 | * Make bower_components available for the resolvers
13 | */
14 | resolve: {
15 | root: [path.join(__dirname, "./bower_components")],
16 | alias: {
17 | appConstants: "./" + ENV + ".constants.js"
18 | }
19 | },
20 | /**
21 | * Entry
22 | * Reference: http://webpack.github.io/docs/configuration.html#entry
23 | * Should be an empty object if it's generating a test build
24 | * Karma will set this when it's a test build
25 | */
26 | entry: {},
27 | /**
28 | * ESLint
29 | * use the .eslint config
30 | * optionally enable autofix to force rules
31 | */
32 | eslint: {
33 | configFile: '.eslintrc',
34 | //fix: true
35 | },
36 | /**
37 | * Output
38 | * Reference: http://console.github.io/docs/configuration.html#output
39 | * Should be an empty object if it's generating a test build
40 | * Karma will handle setting it up for you when it's a test build
41 | */
42 | output: {},
43 | /**
44 | * Devtool settings
45 | * Reference: http://webpack.github.io/docs/configuration.html#devtool
46 | */
47 | devtool: '#inline-source-map',
48 |
49 | /**
50 | * Loaders
51 | * Reference: http://webpack.github.io/docs/configuration.html#module-loaders
52 | * List: http://webpack.github.io/docs/list-of-loaders.html
53 | * This handles most of the magic responsible for converting modules
54 | */
55 | module: {
56 | preloaders: [{
57 | test: /\.js$/,
58 | exclude: [
59 | /node_modules/,
60 | /\.test\.js$/
61 | ],
62 | loader: 'isparta-instrumenter'
63 | }],
64 | loaders: [{
65 | // JS LOADER
66 | // Reference: https://github.com/babel/babel-loader
67 | test: /\.(js|jsx)$/,
68 | loader: 'babel',
69 | exclude: [/node_modules/, /bower_components/]
70 | }, {
71 | // ASSET LOADER
72 | // Reference: https://github.com/webpack/file-loader
73 | // Copy png, jpg, jpeg, gif, svg, woff, woff2, ttf, eot files to output
74 | // Rename the file using the asset hash
75 | // Pass along the updated reference to your code
76 | // You can add here any file extension you want to get copied to your output
77 | test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/,
78 | loader: "file-loader?name=[name].[ext]"
79 | }, {
80 | // HTML LOADER
81 | // Reference: https://github.com/webpack/raw-loader
82 | // Allow loading html through js
83 | test: /\.html$/,
84 | loader: 'raw'
85 | }, {
86 | // Sass Loader
87 | test: /\.scss$/,
88 | loaders: ["style", "css", "sass"]
89 | }, {
90 | // ESLint loader
91 | test: /\.js$/,
92 | loader: "eslint-loader",
93 | exclude: [/node_modules/, /bower_components/]
94 | }]
95 | },
96 | /**
97 | * Plugins
98 | * Reference: http://webpack.github.io/docs/configuration.html#plugins
99 | * List: http://webpack.github.io/docs/list-of-plugins.html
100 | */
101 | plugins: [
102 | new ngAnnotatePlugin({
103 | add: true,
104 | // other ng-annotate options here
105 | }),
106 | new webpack.ResolverPlugin(
107 | new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin(
108 | "../bower.json", ["main"])
109 | )
110 | ]
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/generators/app/content/config/webpack.make.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | // Modules
4 | var _ = require('lodash');
5 |
6 | var defaultConfig = require('./webpack.config.default');
7 | var buildConfig = require('./webpack.config.build');
8 | var moduleConfig = require('./webpack.config.module');
9 | var serveConfig = require('./webpack.config.serve');
10 | var testConfig = require('./webpack.config.test');
11 |
12 | module.exports = function makeWebpackConfig(options) {
13 | /**
14 | * Environment type
15 | * BUILD is for generating minified builds
16 | * TEST is for generating test builds
17 | */
18 | var TYPE = options.TYPE;
19 | var ENV = options.ENVIRONMENT;
20 | var configOptions = {
21 | devServerPort: 8080
22 | };
23 |
24 | // Prepare config object
25 | var config = defaultConfig(ENV, configOptions);
26 |
27 | switch (TYPE) {
28 | case 'build':
29 | var newConfig = buildConfig(ENV, configOptions);
30 | // Make sure to apply modules plugins first
31 | config.plugins = newConfig.plugins.push.apply(newConfig.plugins, config.plugins);
32 | merge(config, newConfig);
33 | break;
34 | case 'build-module':
35 | var newConfig = moduleConfig(ENV, configOptions);
36 | // Make sure to apply modules plugins first
37 | config.plugins = newConfig.plugins.push.apply(newConfig.plugins, config.plugins);
38 | merge(config, newConfig);
39 | break;
40 | case 'serve':
41 | console.log("running serve");
42 | merge(config, serveConfig(ENV, configOptions));
43 | break;
44 | case 'test':
45 | config = testConfig(ENV, configOptions);
46 | break;
47 | default:
48 | console.log("running default")
49 | }
50 |
51 | return config;
52 |
53 | };
54 |
55 | /**
56 | * Helper funciton for merging configs
57 | * @param {[type]} destination [description]
58 | * @param {[type]} source [description]
59 | */
60 | function merge(destination, source){
61 | _.merge(destination, source, function(a, b) {
62 | if (_.isArray(a)) {
63 | return a.concat(b);
64 | }
65 | });
66 | }
67 |
--------------------------------------------------------------------------------
/generators/app/content/config/webpack.tests.js:
--------------------------------------------------------------------------------
1 | // This file is an entry point for angular tests
2 | // Avoids some weird issues when using webpack + angular.
3 |
4 | import 'angular';
5 | import 'angular-mocks/angular-mocks';
6 |
7 | var testsContext = require.context("../client", true, /.spec$/);
8 | testsContext.keys().forEach(testsContext);
9 |
--------------------------------------------------------------------------------
/generators/app/content/index.js:
--------------------------------------------------------------------------------
1 | /* global __WEBPACK__ */
2 | // only load style when using webpack
3 | require('./client/app/app.scss');
4 |
5 | // code
6 | import app from './client/app/app';
7 |
8 | export default app;
9 |
--------------------------------------------------------------------------------
/generators/app/content/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Reference: http://karma-runner.github.io/0.12/config/configuration-file.html
2 | module.exports = function karmaConfig (config) {
3 | config.set({
4 | frameworks: [
5 | // Reference: https://github.com/karma-runner/karma-jasmine
6 | // Set framework to jasmine
7 | 'jasmine'
8 | ],
9 | plugins: [
10 | require('phantomjs-polyfill'),
11 | require("karma-webpack"),
12 | require("karma-coverage"),
13 | require("karma-spec-reporter"),
14 | require("karma-sourcemap-loader"),
15 | require("karma-phantomjs-launcher"),
16 | require("karma-jasmine")
17 | ],
18 | reporters: [
19 | // Reference: https://github.com/mlex/karma-spec-reporter
20 | // Set reporter to print detailed results to console
21 | 'spec',
22 |
23 | // Reference: https://github.com/karma-runner/karma-coverage
24 | // Output code coverage files
25 | 'coverage'
26 | ],
27 |
28 | files: [
29 | // Grab all files in the app folder that contain .spec.
30 | //
31 | './node_modules/phantomjs-polyfill/bind-polyfill.js',
32 | './config/webpack.tests.js'
33 | ],
34 |
35 | preprocessors: {
36 | // Reference: http://webpack.github.io/docs/testing.html
37 | // Reference: https://github.com/webpack/karma-webpack
38 | // Convert files with webpack and load sourcemaps
39 | './config/webpack.tests.js': ['webpack', 'sourcemap']
40 | },
41 |
42 | browsers: [
43 | // Run tests using PhantomJS
44 | 'PhantomJS'
45 | ],
46 |
47 | singleRun: true,
48 |
49 | // Configure code coverage reporter
50 | coverageReporter: {
51 | dir: 'build/coverage/',
52 | type: 'html'
53 | },
54 |
55 | webpack: require('./webpack.config'),
56 |
57 | // Hide webpack build information from output
58 | webpackMiddleware: {
59 | noInfo: true
60 | }
61 | });
62 | };
63 |
--------------------------------------------------------------------------------
/generators/app/content/webpack.config.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | var program = require('commander');
4 |
5 | program
6 | .option('-inline, --inline', 'Whether to run with auto refresh')
7 | .option('-p, --production', 'Whether to run for production')
8 | .option('-progress, --progress', 'Whether to display progress')
9 | .option('-bail, --bail', 'Whether to bail on error')
10 | .option('-type, --type ', 'Whether to build as module', 'default')
11 | .option('-env, --env ', 'The environment to run it in', 'local')
12 | .parse(process.argv);
13 |
14 | /**
15 | * Webpack config for development
16 | */
17 | module.exports = require('./config/webpack.make')({
18 | TYPE: program.type,
19 | ENVIRONMENT: program.env
20 | });
21 |
--------------------------------------------------------------------------------
/generators/app/index.js:
--------------------------------------------------------------------------------
1 | var generators = require('yeoman-generator');
2 | var mkdirp = require('mkdirp');
3 |
4 | module.exports = generators.Base.extend({
5 | promptUser: function () {
6 | var done = this.async();
7 |
8 | // have Yeoman greet the user
9 |
10 | var prompts = [
11 | {
12 | name: 'name',
13 | message: "What is the name of the app you're building? "
14 | },
15 | {
16 | name: 'description',
17 | message: "Provide an app description: "
18 | }];
19 |
20 | this.prompt(prompts, function(props){
21 | this.name = props.name
22 | this.description = props.description
23 |
24 | done();
25 | }.bind(this))
26 | },
27 | scaffoldFolders: function(){
28 | mkdirp.sync("bower_components");
29 | mkdirp.sync("client");
30 | mkdirp.sync("client/assets");
31 | mkdirp.sync("client/assets/fonts");
32 | mkdirp.sync("client/assets/images");
33 | mkdirp.sync("client/app");
34 | mkdirp.sync("client/app/components");
35 | mkdirp.sync("client/app/features");
36 | mkdirp.sync("client/app/shared");
37 | },
38 | copyContent: function(){
39 | this.directory('../content', '.');
40 | },
41 | copyMainFiles: function(){
42 | var context = {
43 | appName: this.name,
44 | appDescription : this.description
45 | }
46 |
47 | this.copy('../../../README.md', 'README.md');
48 | this.template("_bower.json", 'bower.json', context);
49 | this.template("_package.json", 'package.json', context);
50 | this.template("_index.html", 'client/index.html', context);
51 | this.template("client/app/_app.js", "client/app/app.js", context);
52 | },
53 | installDependencies: function(){
54 | this.npmInstall();
55 | }
56 |
57 | });
58 |
--------------------------------------------------------------------------------
/generators/app/templates/_bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "<%= appName %>",
3 | "description": "<%= appDescription %>",
4 | "main": "./client/app/app.js",
5 | "authors": [
6 | "Aleksander Herforth Rendtslev "
7 | ],
8 | "license": "MIT",
9 | "moduleType": [],
10 | "homepage": "",
11 | "ignore": [
12 | "**/.*",
13 | "node_modules",
14 | "bower_components",
15 | "test",
16 | "tests"
17 | ],
18 | "dependencies": {}
19 | }
20 |
--------------------------------------------------------------------------------
/generators/app/templates/_index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | <%= appName %>
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/generators/app/templates/_package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "<%= appName %>",
3 | "version": "1.0.0",
4 | "description": "<%= appDescription %>",
5 | "scripts": {
6 | "build": "npm run build:dist && npm run build:module",
7 | "build:dev": "webpack --bail -p --type build --env dev",
8 | "build:dist": "webpack --bail -p --type build --env prod --progress",
9 | "build:module": "webpack --bail --type build-module --env prod --progress",
10 | "serve": "webpack-dev-server --inline --type serve",
11 | "serve:dev": "webpack-dev-server --env dev --type serve --inline",
12 | "serve:prod": "webpack-dev-server --env prod --type serve --inline",
13 | "test": "karma start --type test",
14 | "test:live": "karma start --type test --auto-watch --no-single-run",
15 | "prepublish": "npm run build"
16 | },
17 | "license": "MIT",
18 | "dependencies": {
19 | "angular": "^1.4.8",
20 | "angular-ui-router": "^0.2.15"
21 | },
22 | "devDependencies": {
23 | "angular-mocks": "^1.4.8",
24 | "autoprefixer": "^6.0.3",
25 | "babel-core": "^6.3.15",
26 | "babel-eslint": "^5.0.0-beta4",
27 | "babel-loader": "^6.2.0",
28 | "babel-plugin-syntax-flow": "^6.3.13",
29 | "babel-plugin-transform-flow-strip-types": "^6.3.15",
30 | "babel-preset-es2015": "^6.3.13",
31 | "babel-preset-stage-0": "^6.3.13",
32 | "babel-runtime": "^6.3.13",
33 | "browser-sync": "^2.10.0",
34 | "browser-sync-webpack-plugin": "^1.0.1",
35 | "commander": "^2.9.0",
36 | "css-loader": "^0.21.0",
37 | "eslint": "^1.10.3",
38 | "eslint-loader": "^1.1.1",
39 | "extract-text-webpack-plugin": "^0.8.2",
40 | "file-loader": "^0.8.5",
41 | "html-webpack-plugin": "^1.6.2",
42 | "isparta-instrumenter-loader": "^1.0.0",
43 | "jasmine-core": "^2.3.4",
44 | "karma": "^0.13.14",
45 | "karma-coverage": "^0.5.3",
46 | "karma-jasmine": "^0.3.6",
47 | "karma-phantomjs-launcher": "^0.2.1",
48 | "karma-sourcemap-loader": "^0.3.6",
49 | "karma-spec-reporter": "0.0.21",
50 | "karma-webpack": "^1.7.0",
51 | "lodash": "^3.10.1",
52 | "matchdep": "^1.0.0",
53 | "ng-annotate-webpack-plugin": "^0.1.2",
54 | "node-libs-browser": "^0.5.3",
55 | "node-sass": "^3.4.2",
56 | "null-loader": "^0.1.1",
57 | "phantomjs": "^1.9.18",
58 | "phantomjs-polyfill": "0.0.1",
59 | "postcss-loader": "^0.7.0",
60 | "raw-loader": "^0.5.1",
61 | "sass-loader": "^3.1.2",
62 | "style-loader": "^0.13.0",
63 | "webpack": "^1.12.9",
64 | "webpack-dev-server": "^1.14.0"
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/_app.js:
--------------------------------------------------------------------------------
1 | // Import Style
2 | import './app.scss';
3 |
4 | import angular from 'angular';
5 | import uirouter from 'angular-ui-router';
6 |
7 | // Import base modules
8 | import config from './app.config';
9 | import routes from './app.routes';
10 | import run from './app.run';
11 | import appConstants from 'appConstants';
12 |
13 | // Import internal modules
14 | import sampleModule from './features/sample';
15 |
16 | export default angular.module('<%=appName%>', [uirouter, sampleModule])
17 | .config(config)
18 | .config(routes)
19 | .constant("AppConstants", appConstants)
20 | .run(run)
21 | .name;
22 |
--------------------------------------------------------------------------------
/generators/component/index.js:
--------------------------------------------------------------------------------
1 | var generators = require('yeoman-generator');
2 | var mkdirp = require('mkdirp');
3 | var path = require('path');
4 |
5 | module.exports = generators.NamedBase.extend({
6 | promptUser: function () {
7 | var done = this.async();
8 |
9 | var prompts = [
10 | {
11 | name: 'includeRun',
12 | message: "Should your directive have a run function?",
13 | default: false
14 | },
15 | {
16 | name: 'includeConfig',
17 | message: "Should your directive have a config function?",
18 | default: false
19 | },
20 | {
21 | name: 'bindToElement',
22 | message: "Should your directive be restricted to Element?",
23 | default: true
24 | },
25 | {
26 | name: 'bindToAttribute',
27 | message: "Should your directive be restricted to Attribute?",
28 | default: true
29 | }
30 | ];
31 |
32 | this.prompt(prompts, function(props){
33 | this.includeRun = props.includeRun
34 | this.includeConfig = props.includeConfig
35 | this.bindToElement = props.bindToElement
36 | this.bindToAttribute = props.bindToAttribute
37 |
38 | done();
39 | }.bind(this))
40 | },
41 | copyMainFiles: function(){
42 | this.destinationRoot(path.join('client/app/components', this.name));
43 | var context = {
44 | directiveName: this.name,
45 | includeRun : this.includeRun,
46 | includeConfig : this.includeConfig,
47 | bindToElement : this.bindToElement,
48 | bindToAttribute : this.bindToAttribute
49 | }
50 |
51 | if(this.includeRun){
52 | this.template("_run.js", this.name +".run.js", context);
53 | }
54 | if(this.includeConfig){
55 | this.template("_config.js", this.name +".config.js", context);
56 | }
57 | this.template("_tpl.html", this.name +".tpl.html", context);
58 | this.template("_directive.js", this.name +".directive.js", context);
59 | this.template("_controller.js", this.name +".controller.js", context);
60 | this.template("_index.js", "index.js", context);
61 | this.template("_.scss", this.name+".scss", context);
62 | }
63 | });
64 |
--------------------------------------------------------------------------------
/generators/component/templates/_.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aleksion/generator-angular-webpack-babel/31979cd0f70b52a6e668584e83e36c2671f4606c/generators/component/templates/_.scss
--------------------------------------------------------------------------------
/generators/component/templates/_config.js:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * Run function for <%= directiveName %>
4 | * @param $stateProvider [description]
5 | */
6 | /* @ngInject */
7 | export default function config() {
8 | }
9 |
--------------------------------------------------------------------------------
/generators/component/templates/_controller.js:
--------------------------------------------------------------------------------
1 | export default class <%=directiveName%>Controller {
2 | static get UID(){
3 | return "<%=directiveName+"Controller"%>"
4 | }
5 |
6 | /* @ngInject */
7 | constructor() {
8 | this.title = "<%= "I am a "+ directiveName+" component"%>"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/generators/component/templates/_directive.js:
--------------------------------------------------------------------------------
1 | import controller from '<%= "./"+directiveName+".controller" %>'
2 |
3 | export default function <%=directiveName%>(){
4 | return {
5 | restrict: '<% if(bindToElement) {%>E<% }if(bindToAttribute){%>A<% } %>',
6 | scope: {
7 |
8 | },
9 | template: require("<%="./"+directiveName+".tpl.html" %>"),
10 | controller: controller.UID,
11 | controllerAs: "vm",
12 | bindToController: true,
13 | link: (scope, el, attr, ctrl) => {
14 |
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/generators/component/templates/_index.js:
--------------------------------------------------------------------------------
1 | // Import Style
2 | import '<%= "./"+directiveName+".scss" %>';
3 |
4 |
5 | import angular from 'angular';
6 |
7 | // Import internal modules
8 | import controller from '<%= "./"+directiveName+".controller" %>';
9 | import directive from '<%= "./"+directiveName+".directive" %>';
10 | <%_ if(includeRun){ _%>
11 | import run from '<%= "./"+directiveName+".run" %>';
12 | <%_ } %>
13 | <%_ if(includeConfig){ _%>
14 | import config from '<%= "./"+directiveName+".config" %>';
15 | <%_ } %>
16 |
17 | export default angular.module("<%= directiveName %>" , [])
18 | <%_ if(includeConfig){ _%> .config(config)<%_ } %>
19 | <%_ if(includeRun){ _%> .run(run) <%_ } %>
20 | .controller(controller.UID, controller)
21 | .directive("<%= directiveName %>", directive)
22 | .name;
23 |
--------------------------------------------------------------------------------
/generators/component/templates/_run.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Run function for <%= directiveName %>
3 | * @param $stateProvider [description]
4 | */
5 | /* @ngInject */
6 | export default function run() {
7 | }
8 |
--------------------------------------------------------------------------------
/generators/component/templates/_tpl.html:
--------------------------------------------------------------------------------
1 |
2 | {{vm.title}}
3 |
4 |
--------------------------------------------------------------------------------
/generators/feature/index.js:
--------------------------------------------------------------------------------
1 | var generators = require('yeoman-generator');
2 | var mkdirp = require('mkdirp');
3 | var path = require('path');
4 |
5 | module.exports = generators.NamedBase.extend({
6 | promptUser: function () {
7 | var done = this.async();
8 |
9 | var prompts = [
10 | {
11 | name: 'includeRun',
12 | type: 'confirm',
13 | message: "Should your feature have a run function?",
14 | default: true
15 | },
16 | {
17 | name: 'includeConfig',
18 | type: 'confirm',
19 | message: "Should your feature have a config function?",
20 | default: true
21 | }];
22 |
23 | this.prompt(prompts, function(props){
24 | this.includeRun = props.includeRun
25 | this.includeConfig = props.includeConfig
26 |
27 | done();
28 | }.bind(this))
29 | },
30 | copyMainFiles: function(){
31 | this.destinationRoot(path.join('client/app/features', this.name));
32 | var context = {
33 | featureName: this.name,
34 | includeRun : this.includeRun,
35 | includeConfig : this.includeConfig
36 | }
37 |
38 | if(this.includeRun){
39 | this.template("_run.js", this.name +".run.js", context);
40 | }
41 | if(this.includeConfig){
42 | this.template("_config.js", this.name +".config.js", context);
43 | }
44 | this.template("_tpl.html", this.name +".tpl.html", context);
45 | this.template("_routes.js", this.name +".routes.js", context);
46 | this.template("_controller.js", this.name +".controller.js", context);
47 | this.template("_index.js", "index.js", context);
48 | this.template("_.scss", this.name+".scss", context);
49 | }
50 | });
51 |
--------------------------------------------------------------------------------
/generators/feature/templates/_.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aleksion/generator-angular-webpack-babel/31979cd0f70b52a6e668584e83e36c2671f4606c/generators/feature/templates/_.scss
--------------------------------------------------------------------------------
/generators/feature/templates/_config.js:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * Run function for <%= featureName %>
4 | * @param $stateProvider [description]
5 | */
6 | /* @ngInject */
7 | export default function config() {
8 | }
9 |
--------------------------------------------------------------------------------
/generators/feature/templates/_controller.js:
--------------------------------------------------------------------------------
1 |
2 | export default class <%=featureName%>Controller {
3 | static get UID(){
4 | return "<%=featureName+"Controller"%>"
5 | }
6 |
7 | /* @ngInject */
8 | constructor() {
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/generators/feature/templates/_index.js:
--------------------------------------------------------------------------------
1 | // Import Style
2 | import '<%= "./"+featureName+".scss" %>';
3 |
4 |
5 | import angular from 'angular';
6 | import uirouter from 'angular-ui-router';
7 |
8 | // Import internal modules
9 | import controller from '<%= "./"+featureName+".controller" %>';
10 | import routes from '<%= "./"+featureName+".routes" %>';
11 | <%_ if(includeRun){ _%>
12 | import run from '<%= "./"+featureName+".run" %>';
13 | <%_ } %>
14 | <%_ if(includeConfig){ _%>
15 | import config from '<%= "./"+featureName+".config" %>';
16 | <%_ } %>
17 |
18 | export default angular.module("<%= featureName %>" , [uirouter])
19 | <%_ if(includeConfig){ _%> .config(config)<%_ } %>
20 | .config(routes)
21 | <%_ if(includeRun){ _%> .run(run) <%_ } %>
22 | .controller(controller.UID, controller)
23 | .name;
24 |
--------------------------------------------------------------------------------
/generators/feature/templates/_routes.js:
--------------------------------------------------------------------------------
1 |
2 | import controller from '<%= "./"+featureName+".controller" %>'
3 |
4 | /**
5 | * Routing function for <%= featureName %>
6 | * @param $stateProvider
7 | */
8 | /* @ngInject */
9 | export default function routes($stateProvider) {
10 | $stateProvider.state("<%= featureName %>", {
11 | url: "<%="/"+featureName %>",
12 | template: require("<%="./"+featureName+".tpl.html" %>"),
13 | controller: controller.UID,
14 | controllerAs: "<%= featureName %>"
15 | });
16 | }
17 |
--------------------------------------------------------------------------------
/generators/feature/templates/_run.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Run function for <%= featureName %>
3 | * @param $stateProvider [description]
4 | */
5 | /* @ngInject */
6 | export default function run() {
7 | }
8 |
--------------------------------------------------------------------------------
/generators/feature/templates/_tpl.html:
--------------------------------------------------------------------------------
1 |
2 | <%= featureName %>
3 |
4 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "generator-angular-webpack-starter",
3 | "version": "0.2.15",
4 | "description": "A opinioated generator for angular projects utilizing Webpack and Babel",
5 | "files": [
6 | "generators/app",
7 | "generators/feature",
8 | "generators/component"
9 | ],
10 | "repository": {
11 | "type": "git",
12 | "url": "https://github.com/Aleksion/generator-angular-webpack-babel"
13 | },
14 | "keywords": [
15 | "yeoman-generator"
16 | ],
17 | "author": "Aleksander Herforth Rendtslev",
18 | "license": "MIT",
19 | "dependencies": {
20 | "mkdirp": "^0.5.1",
21 | "yeoman-generator": "^0.21.1"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------