From 6988bb9f84e2778bde8a58800ffd6aae163145fa Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 27 Sep 2016 21:31:46 +0200 Subject: [PATCH] =?UTF-8?q?Integraci=C3=B3n=20con=20webpack=20(Beta)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 4 ++-- package.json | 3 +++ pages/main/head.php | 8 +++++++- web/html-service.php | 2 +- webpack.config.js | 15 ++++++++++----- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/app.js b/app.js index eae0c48e..0796bd49 100644 --- a/app.js +++ b/app.js @@ -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': diff --git a/package.json b/package.json index a261580e..1d72c507 100644 --- a/package.json +++ b/package.json @@ -15,5 +15,8 @@ "dependencies": { "mootools": "^1.5.2", "tinymce": "^4.4.3" + }, + "scripts": { + "dev": "webpack-dev-server --devtool eval --inline --progress --colors" } } diff --git a/pages/main/head.php b/pages/main/head.php index 69689893..1bae9239 100755 --- a/pages/main/head.php +++ b/pages/main/head.php @@ -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'); ?> diff --git a/web/html-service.php b/web/html-service.php index b4d0111b..747d54b6 100644 --- a/web/html-service.php +++ b/web/html-service.php @@ -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); diff --git a/webpack.config.js b/webpack.config.js index 6107dab8..d4e3c4f2 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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');