X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fplugins%2Fproject_management%2Fwebpack.production.config.js;fp=skyquake%2Fplugins%2Fproject_management%2Fwebpack.production.config.js;h=23b6a5c635678e5d9d7a74cee6686efc253dbd4d;hp=0000000000000000000000000000000000000000;hb=03156e335275de1dafbc2a816e98006afdf249bf;hpb=f2dc2462571800e62cba969964de621dca09299c diff --git a/skyquake/plugins/project_management/webpack.production.config.js b/skyquake/plugins/project_management/webpack.production.config.js new file mode 100644 index 000000000..23b6a5c63 --- /dev/null +++ b/skyquake/plugins/project_management/webpack.production.config.js @@ -0,0 +1,78 @@ +/* + * STANDARD_RIFT_IO_COPYRIGHT + */ +var webpack = require('webpack'); +var path = require('path'); +var nodeModulesPath = path.resolve(__dirname, 'node_modules'); +var buildPath = path.resolve(__dirname, 'public', 'build'); +var mainPath = path.resolve(__dirname, 'src', 'main.js'); +var uiPluginCmakeBuild = process.env.ui_plugin_cmake_build || false; +var frameworkPath = uiPluginCmakeBuild?'../../../../skyquake/skyquake-build/framework':'../../framework'; +var HtmlWebpackPlugin = require('html-webpack-plugin'); +var CompressionPlugin = require("compression-webpack-plugin"); + +// Added to overcome node-sass bug https://github.com/iam4x/isomorphic-flux-boilerplate/issues/62 +process.env.UV_THREADPOOL_SIZE=64; +var htmlFilename = (process.argv.indexOf('--production-debug') !== -1) ? 'debug.html' : 'index.html'; +var config = { + devtool: 'source-map', + entry: mainPath, + output: { + path: buildPath, + filename: 'bundle.js', + publicPath: "build/" + }, + resolve: { + extensions: ['', '.js', '.jsx', '.css', '.scss'], + root: path.resolve(frameworkPath), + alias: { + 'widgets': path.resolve(frameworkPath) + '/widgets', + 'style': path.resolve(frameworkPath) + '/style', + 'utils': path.resolve(frameworkPath) + '/utils' + } + }, + module: { + loaders: [{ + test: /\.(jpe?g|png|gif|svg|ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/i, + loader: "file-loader" + }, + { + test: /\.(js|jsx)$/, + exclude: /react-treeview/, + loader: 'babel-loader', + query: { + presets: ["es2015", "stage-0", "react"] + } + }, { + test: /\.css$/, + loader: 'style!css' + }, { + test: /\.scss/, + loader: 'style!css!sass?includePaths[]='+ path.resolve(frameworkPath) + } + ] + }, + plugins: [ + new HtmlWebpackPlugin({ + filename: '../' + htmlFilename, + template: frameworkPath + '/plugin-index.html' + }), + ] +}; + +if (process.argv.indexOf('--optimize-minimize') !== -1) { + // we are going to output a gzip file in the production process + config.output.filename = "gzip-" + config.output.filename; + config.plugins.push(new webpack.DefinePlugin({ // <-- key to reducing React's size + 'process.env': { + 'NODE_ENV': JSON.stringify('production') + } + })); + config.plugins.push(new CompressionPlugin({ + asset: "[path]", // overwrite js file with gz file + algorithm: "gzip", + test: /\.(js)$/ + })); +} + +module.exports = config;