Add webpack for frontend dependency loading
This commit is contained in:
@ -30,6 +30,10 @@ class RoboFile extends \Robo\Tasks {
|
|||||||
$this->_exec(join(' ', $command));
|
$this->_exec(join(' ', $command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bundleJavascript() {
|
||||||
|
$this->_exec('./node_modules/webpack/bin/webpack.js');
|
||||||
|
}
|
||||||
|
|
||||||
function makepot() {
|
function makepot() {
|
||||||
$this->_exec('grunt makepot'.
|
$this->_exec('grunt makepot'.
|
||||||
' --gruntfile '.__DIR__.'/tasks/makepot/makepot.js'.
|
' --gruntfile '.__DIR__.'/tasks/makepot/makepot.js'.
|
||||||
@ -61,6 +65,11 @@ class RoboFile extends \Robo\Tasks {
|
|||||||
$this->_exec('vendor/bin/codecept run acceptance');
|
$this->_exec('vendor/bin/codecept run acceptance');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testJavascript() {
|
||||||
|
// TODO: regenerate test bundle before running mocha tests
|
||||||
|
$this->_exec('./node_modules/mocha/bin/mocha -r tests/javascript/mochaTestHelper.js tests/javascript/newsletter_editor/testBundle.js');
|
||||||
|
}
|
||||||
|
|
||||||
function testAll() {
|
function testAll() {
|
||||||
$this->_exec('vendor/bin/codecept build');
|
$this->_exec('vendor/bin/codecept build');
|
||||||
$this->loadEnv();
|
$this->loadEnv();
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
"sinon": "1.14.1",
|
"sinon": "1.14.1",
|
||||||
"sinon-chai": "2.7.0",
|
"sinon-chai": "2.7.0",
|
||||||
"stylus": "latest",
|
"stylus": "latest",
|
||||||
"swag": "~0.7.0"
|
"swag": "~0.7.0",
|
||||||
|
"webpack": "1.11.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
28
tests/javascript/mochaTestHelper.js
Normal file
28
tests/javascript/mochaTestHelper.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
var chai = require('chai');
|
||||||
|
var sinon = require('sinon');
|
||||||
|
var sinonChai = require('sinon-chai');
|
||||||
|
var chaiJq = require('chai-jq');
|
||||||
|
|
||||||
|
chai.use(sinonChai);
|
||||||
|
chai.use(chaiJq);
|
||||||
|
|
||||||
|
global.expect = chai.expect;
|
||||||
|
global.sinon = sinon;
|
||||||
|
|
||||||
|
if (!global.document || !global.window) {
|
||||||
|
var jsdom = require('jsdom').jsdom;
|
||||||
|
|
||||||
|
global.document = jsdom('<html><head><script></script></head><body></body></html>', {}, {
|
||||||
|
FetchExternalResources: ['script'],
|
||||||
|
ProcessExternalResources: ['script'],
|
||||||
|
MutationEvents: '2.0',
|
||||||
|
QuerySelector: false
|
||||||
|
});
|
||||||
|
|
||||||
|
global.window = document.parentWindow;
|
||||||
|
global.navigator = global.window.navigator;
|
||||||
|
|
||||||
|
global.window.Node.prototype.contains = function (node) {
|
||||||
|
return this.compareDocumentPosition(node) & 16;
|
||||||
|
};
|
||||||
|
}
|
@ -31,4 +31,4 @@
|
|||||||
)%>
|
)%>
|
||||||
|
|
||||||
<!-- handlebars templates -->
|
<!-- handlebars templates -->
|
||||||
<% block templates %><% endblock %>
|
<% block templates %><% endblock %>
|
||||||
|
45
webpack.config.js
Normal file
45
webpack.config.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
var path = require('path'),
|
||||||
|
fs = require('fs');
|
||||||
|
|
||||||
|
// webpack.config.js
|
||||||
|
module.exports = {
|
||||||
|
context: __dirname ,
|
||||||
|
entry: {
|
||||||
|
mailpoet: './assets/js/mailpoet',
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
path: './assets/js/src',
|
||||||
|
filename: '[name].js',
|
||||||
|
},
|
||||||
|
loaders: [
|
||||||
|
{
|
||||||
|
test: /\.js$/i,
|
||||||
|
loader: 'js'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.css$/i,
|
||||||
|
loader: 'css'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.jpe?g$|\.gif$|\.png$|\.svg$|\.woff$|\.ttf$|\.wav$|\.mp3$/i,
|
||||||
|
loader: 'file'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
resolve: {
|
||||||
|
modulesDirectories: [
|
||||||
|
'node_modules',
|
||||||
|
'assets/js',
|
||||||
|
'assets/css/lib'
|
||||||
|
],
|
||||||
|
fallback: path.join(__dirname, 'node_modules'),
|
||||||
|
alias: {
|
||||||
|
'handlebars': 'handlebars/runtime.js'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
resolveLoader: {
|
||||||
|
fallback: path.join(__dirname, 'node_modules'),
|
||||||
|
alias: {
|
||||||
|
'hbs': 'handlebars-loader'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
Reference in New Issue
Block a user