Integración con webpack (Beta)

This commit is contained in:
Juan Ferrer Toribio 2016-09-27 21:31:46 +02:00
parent 8369d48584
commit 6988bb9f84
5 changed files with 23 additions and 9 deletions

4
app.js
View File

@ -25,11 +25,11 @@ function loadLocale (lang, cb)
switch (lang)
{
case 'ca':
require ([], function (){
require ([], function (){
cb (require.context ('locale/ca/js')); });
break;
case 'es':
require ([], function () {
require ([], function () {
cb (require.context ('locale/es/js')); });
break;
case 'fr':

View File

@ -15,5 +15,8 @@
"dependencies": {
"mootools": "^1.5.2",
"tinymce": "^4.4.3"
},
"scripts": {
"dev": "webpack-dev-server --devtool eval --inline --progress --colors"
}
}

View File

@ -12,6 +12,12 @@ if ($result = $db->query ('SELECT name, content FROM metatag'))
$result->free ();
}
$this->includeJs ('hedera-web.js');
if (DEBUG_MODE)
{
$this->includeJs ('http://localhost:8080/webpack-dev-server.js');
$this->includeJs ('http://localhost:8080/build/hedera-web.js');
}
else
$this->includeJs ('build/hedera-web.js');
?>

View File

@ -14,7 +14,7 @@ class HtmlService extends Service
$db = $this->db;
if (!$this->isHttps ()
&& $db->getValue ('SELECT https FROM config'))
&& $db->getValue ('SELECT https FROM config') && !DEBUG_MODE)
{
header ("Location: https://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}");
exit (0);

View File

@ -1,19 +1,22 @@
var fs = require ('fs');
var webpack = require ('webpack');
var path = require ('path');
var devMode = true;
module.exports =
{
entry: './app.js',
entry: ['./app.js'],
output: {
path: __dirname,
filename: 'hedera-web.js'
path: path.join (__dirname, 'build'),
filename: 'hedera-web.js',
chunkFilename: 'chunk.[id].js',
publicPath: devMode ? 'http://localhost:8080/build/' : 'build/',
},
module: {
loaders: [
{ test: /\.css$/, loader: 'style!css' },
{ test: /\.json$/, loader: 'json' },
{ test: /\.png$/, loader: 'file' },
{ test: /\.xml$/, loader: 'raw' }
]
},
@ -30,6 +33,8 @@ module.exports =
*/ ]
};
/*
var fs = require ('fs');
var configs = [];
var langs = fs.readdirSync ('./locale');