diff --git a/.gitignore b/.gitignore index 3e9ecd618..1dc6e019a 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,8 @@ app_instance/ webui/app/b2share-bundle.js webui/app/b2share-bundle.js.map webui/app/lib/ +webui/app/index.html +webui/app/js/ webui/app/vendors/ webui/src/version.js -webui/package-lock.json \ No newline at end of file +webui/package-lock.json diff --git a/webui/package.json b/webui/package.json index e2b8b4cf3..497499622 100644 --- a/webui/package.json +++ b/webui/package.json @@ -36,10 +36,12 @@ }, "dependencies": { "bootstrap": "^3.3.6", + "clean-webpack-plugin": "^1.0.1", "dotenv-webpack": "^1.5.7", "fast-json-patch": "^0.5.6", "font-awesome": "^4.4.0", "history": "^3.3.0", + "html-webpack-plugin": "^2.30.1", "immutable": "^3.7.6", "lodash": "^4.17.20", "moment": "^2.29.1", diff --git a/webui/app/index.html b/webui/templates/index_template.html similarity index 92% rename from webui/app/index.html rename to webui/templates/index_template.html index 07f6135e3..41c5975fe 100644 --- a/webui/app/index.html +++ b/webui/templates/index_template.html @@ -29,7 +29,7 @@ - +
- - + + diff --git a/webui/webpack.config.devel.js b/webui/webpack.config.devel.js index 2ff54ad42..ac54c6612 100644 --- a/webui/webpack.config.devel.js +++ b/webui/webpack.config.devel.js @@ -2,13 +2,22 @@ var path = require('path'); var webpack = require('webpack'); const Dotenv = require('dotenv-webpack'); var WatchTimePlugin = require('webpack-watch-time-plugin'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const CleanWebpackPlugin = require('clean-webpack-plugin'); console.log("Using configuration file from", __dirname+'/../webui.cfg'); +let cleanOptions = { + root: __dirname+'/app', + verbose: true, + dry: false +} + + module.exports = { entry: ['./src/main.jsx'], devtool: 'cheap-module-eval-source-map', - output: { path: __dirname+"/app", filename: 'b2share-bundle.js' }, + output: { path: __dirname+"/app/", filename: 'js/b2share-bundle.[hash].js'}, plugins: [ // Note: Only values used in source code will be included in the bundle. // See dotenv-webpack documentation for more details. @@ -16,7 +25,16 @@ module.exports = { path: __dirname+'/../webui.cfg', // load this file instead of '.env'. systemvars: true, // load environment variables from 'process.env'. }), - WatchTimePlugin + WatchTimePlugin, + new CleanWebpackPlugin('js', cleanOptions), + //inject false prevents script tag from being automatically injected + //the script tag is injected directly in index_template.html code instead + new HtmlWebpackPlugin({ + inject: false, + hash: false, + template: 'templates/index_template.html', + filename: 'index.html' + }), ], module: { loaders: [ diff --git a/webui/webpack.config.js b/webui/webpack.config.js index 3d75459d6..868be8f60 100644 --- a/webui/webpack.config.js +++ b/webui/webpack.config.js @@ -1,13 +1,23 @@ var path = require('path'); var webpack = require('webpack'); const Dotenv = require('dotenv-webpack'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const CleanWebpackPlugin = require('clean-webpack-plugin'); console.log("Using configuration file from", __dirname+'/../webui.cfg'); +let cleanOptions = { + root: __dirname+'/app', + verbose: true, + dry: false +} + + + module.exports = { entry: ['./src/main.jsx'], devtool: 'source-map', - output: { path: __dirname+"/app", filename: 'b2share-bundle.js' }, + output: { path: __dirname+"/app/", filename: 'js/b2share-bundle.[hash].js'}, plugins: [ new webpack.DefinePlugin({ 'process.env': { @@ -22,6 +32,17 @@ module.exports = { }), new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/), // trim down moment.js new webpack.optimize.OccurenceOrderPlugin(), + + new CleanWebpackPlugin('js', cleanOptions), + + //inject false prevents script tag from being automatically injected + //the script tag is injected directly in index_template.html code instead + new HtmlWebpackPlugin({ + inject: false, + hash: false, + template: 'templates/index_template.html', + filename: 'index.html' + }), new webpack.optimize.DedupePlugin(), new webpack.optimize.UglifyJsPlugin({ compressor: {