Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[~FEATURE] Concatenate core js files #134

Open
wants to merge 6 commits into
base: 2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,24 @@
<name>varien/menu.js</name>
</action>

<action method="removeItem"><type>js</type><file>prototype/prototype.js</file></action>
<action method="removeItem"><type>js</type><file>lib/ccard.js</file></action>
<action method="removeItem"><type>js</type><file>prototype/validation.js</file></action>
<action method="removeItem"><type>js</type><file>scriptaculous/builder.js</file></action>
<action method="removeItem"><type>js</type><file>scriptaculous/effects.js</file></action>
<action method="removeItem"><type>js</type><file>scriptaculous/dragdrop.js</file></action>
<action method="removeItem"><type>js</type><file>scriptaculous/controls.js</file></action>
<action method="removeItem"><type>js</type><file>scriptaculous/slider.js</file></action>
<action method="removeItem"><type>js</type><file>varien/js.js</file></action>
<action method="removeItem"><type>js</type><file>varien/form.js</file></action>
<action method="removeItem"><type>js</type><file>mage/translate.js</file></action>
<action method="removeItem"><type>js</type><file>mage/cookies.js</file></action>

<!-- Add our assets -->
<action method="addCss">
<stylesheet>css/style.css</stylesheet>
</action>
<action method="addJs"><name>mage.js</name></action>
<action method="addItem">
<type>skin_js</type>
<name>js/script.js</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ $index = 0;
?>
<?php if ($baseImageFile): ?>
<div class="product-image product-image-zoom">
<a href="#product-media-modal" data-toggle="media" data-index="<?php echo $index++ ?>">
<a href="#product-media-modal" data-toggle="modal" data-index="<?php echo $index++ ?>">
<img src="<?php echo $this->helper('catalog/image')->init($product, 'image')->resize($baseImageSize['x'], $baseImageSize['y']) ?>" alt="<?php echo $this->htmlEscape($this->getImageLabel()) ?>">
</a>
</div>
Expand All @@ -82,7 +82,7 @@ $index = 0;
<ul>
<?php foreach ($galleryImages as $image): ?>
<li>
<a href="#product-media-modal" data-toggle="media" data-index="<?php echo $index++ ?>">
<a href="#product-media-modal" data-toggle="modal" data-index="<?php echo $index++ ?>">
<img src="<?php echo $this->helper('catalog/image')->init($product, 'image', $image->getFile())->resize($galleryImageSize['x'], $galleryImageSize['y']) ?>" alt="<?php echo $this->htmlEscape($image->getLabel()) ?>">
</a>
</li>
Expand Down
34 changes: 30 additions & 4 deletions skin/frontend/boilerplate/default/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var
concat = require('gulp-concat'),
notify = require('gulp-notify'),
cache = require('gulp-cache'),
merge = require('merge-stream'),
livereload = require('gulp-livereload');

var config = {
Expand Down Expand Up @@ -67,6 +68,28 @@ gulp.task('css', function() {

// JS
gulp.task('js', function() {
var core = [
'../../../../js/prototype/prototype.js',
'../../../../js/lib/ccard.js',
'../../../../js/prototype/validation.js',

// Scriptaculous is not needed when using bootstrap
// '../../../../js/scriptaculous/builder.js',
// '../../../../js/scriptaculous/effects.js',
// '../../../../js/scriptaculous/dragdrop.js',
// '../../../../js/scriptaculous/controls.js',
// '../../../../js/scriptaculous/slider.js',

'../../../../js/varien/js.js',
'../../../../js/varien/form.js',
'../../../../js/mage/translate.js',
'../../../../js/mage/cookies.js'
];

var mage = gulp
.src(core)
.pipe(concat('mage.js'));

var scripts = [
'bower_components/jquery/dist/jquery.js',
'bower_components/bootstrap/js/transition.js',
Expand All @@ -81,16 +104,19 @@ gulp.task('js', function() {
scripts.push('src/js/livereload.js');
}

var stream = gulp
var boilerplate = gulp
.src(scripts)
.pipe(concat('script.js'));

if (config.uglifyJS === true) {
stream.pipe(uglify());
mage.pipe(uglify({"mangle":false})); // Do not rename super global variables as it breaks prototype functionality
boilerplate.pipe(uglify());
}

return stream
.pipe(gulp.dest('js'))
mage.pipe(gulp.dest('../../../../js')); // Put concated mage core js file in /js
boilerplate.pipe(gulp.dest('js'));

return merge(mage, boilerplate)
.pipe(notify({ message: 'Successfully compiled JavaScript' }));
});

Expand Down
1 change: 1 addition & 0 deletions skin/frontend/boilerplate/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"gulp-notify": "^1.4.0",
"gulp-rimraf": "^0.1.0",
"gulp-uglify": "^0.3.1",
"merge-stream": "~1.0",
"bower": "~1.3.5",
"grunt": "~0.4.5",
"grunt-autoprefixer": "~0.8.1",
Expand Down