Skip to content

Commit

Permalink
Merge pull request #49 from concerto/auto-tweak-output
Browse files Browse the repository at this point in the history
grunt the tweaking of the vulcanized output file
  • Loading branch information
mfrederickson committed Oct 5, 2015
2 parents a1d69d0 + 20ebf49 commit dac2d1f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
32 changes: 29 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Wrapper function to encapsulate Grunt config
// Wrapper function to encapsulate Grunt config
module.exports = function(grunt) {
// Initialize our Grunt config object
grunt.initConfig({
Expand All @@ -19,6 +19,31 @@ module.exports = function(grunt) {
}
}
},
"regex-replace": {
componentize: {
src: ['concerto-frontend-gem/app/assets/html/concerto_frontend/concerto-frontend.html'],
actions: [
{
name: 'stripstart',
search: /^((?:\s|.)*?)(<script>)/,
replace: '$2',
flags: ''
},
{
name: 'stripvulcan',
search: '(</head.*?>)(<dom-module)',
replace: '$2',
flags: ''
},
{
name: 'stripend',
search: '(</dom-module>)(.*?</html>)',
replace: '$1',
flags: ''
}
]
}
},
// Read NPM package settings and store values in pkg property
pkg: grunt.file.readJSON("package.json"),
// Configure the vulcanize plugin to concatenate our Polymer html files
Expand All @@ -37,7 +62,7 @@ module.exports = function(grunt) {
watch: {
scripts: {
files: ['*.html', 'contents/*.html'],
tasks: ['vulcanize']
tasks: ['vulcanize', 'regex-replace']
},
},
});
Expand All @@ -47,7 +72,8 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-vulcanize'); // concatenate Polymer elements
grunt.loadNpmTasks('grunt-contrib-watch'); // run tasks when files are modified
grunt.loadNpmTasks('grunt-bowercopy'); // copy files to gem
grunt.loadNpmTasks('grunt-regex-replace');

// Set up our default task that is run when 'grunt' is executed
grunt.registerTask('default', ['vulcanize', 'bowercopy']);
grunt.registerTask('default', ['vulcanize', 'regex-replace', 'bowercopy']);
}
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The concerto-frontend gem should be installed by default with the latest Concert

Development
-----------
The concerto-frontend uses web components and the latest [Polymer 1.0](https://www.polymer-project.org/1.0/) library.
The concerto-frontend uses web components and the latest [Polymer 1.0](https://www.polymer-project.org/1.0/) library. External javascripts should be placed in the vendor/assets/javascripts directory and required in the application.js.

#### Dependencies
1. [node js](https://nodejs.org/)
Expand Down Expand Up @@ -49,7 +49,6 @@ The grunt tasks will update the concatenated Polymer web components file and the
#### Building the concerto_frontend gem
The following notes are kept for any developers on the Concerto team that need to push updates to RubyGems:

1. Edit the `concerto-frontend-gem/app/assets/html/concerto_frontend/concerto-frontend.html` (vulcanized output file) and remove everything from the beginning until the first `<script>` tag, then search for the word "vulcanize" and remove the preceding closing `</head>` tag up to the following `<dom-module` tag, then go to the end of the file and remove everything after the closing `</dom-module>` tag.
2. external javascripts (which are no longer vulcanized) should be placed in the vendor/assets/javascripts directory and required in the application.js. This can be accomplished by running `grunt bowercopy`
3. change direcetories to the concerto-frontend-gem and then run ```gem build concerto_frontend.gemspec```
4. push the final gem to RubyGems using ```gem push concerto_frontend-X.X.X.gem``` and add to core Concerto as concerto_frontend with the latest version number
1. Run `grunt` so it performs the default actions of vulcanizing the vulcanize_this.html file, strips the extra html from the vulcanized output file, and copies external js files to the vendor/assets/javascripts directory.
2. change direcetories to the concerto-frontend-gem and then run ```gem build concerto_frontend.gemspec```
3. push the final gem to RubyGems using ```gem push concerto_frontend-X.X.X.gem``` and add to core Concerto as concerto_frontend with the latest version number
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"grunt": "0.4.0",
"grunt-bowercopy": "^1.2.3",
"grunt-contrib-watch": "0.6.1",
"grunt-regex-replace": "^0.2.6",
"grunt-vulcanize": "1.0.0"
},
"repository": {
Expand Down

0 comments on commit dac2d1f

Please sign in to comment.