update from RIFT as of 696b75d2fe9fb046261b08c616f1bcf6c0b54a9b third try
[osm/UI.git] / skyquake / plugins / user_management / webpack.production.config.js
1 /*
2 * STANDARD_RIFT_IO_COPYRIGHT
3 */
4 var webpack = require('webpack');
5 var path = require('path');
6 var nodeModulesPath = path.resolve(__dirname, 'node_modules');
7 var buildPath = path.resolve(__dirname, 'public', 'build');
8 var mainPath = path.resolve(__dirname, 'src', 'main.js');
9 var uiPluginCmakeBuild = process.env.ui_plugin_cmake_build || false;
10 var frameworkPath = uiPluginCmakeBuild?'../../../../skyquake/skyquake-build/framework':'../../framework';
11 var HtmlWebpackPlugin = require('html-webpack-plugin');
12 var CompressionPlugin = require("compression-webpack-plugin");
13
14 // Added to overcome node-sass bug https://github.com/iam4x/isomorphic-flux-boilerplate/issues/62
15 process.env.UV_THREADPOOL_SIZE=64;
16 var htmlFilename = (process.argv.indexOf('--production-debug') !== -1) ? 'debug.html' : 'index.html';
17 var config = {
18 devtool: 'source-map',
19 entry: mainPath,
20 output: {
21 path: buildPath,
22 filename: 'bundle.js',
23 publicPath: "build/"
24 },
25 resolve: {
26 extensions: ['', '.js', '.jsx', '.css', '.scss'],
27 root: path.resolve(frameworkPath),
28 alias: {
29 'widgets': path.resolve(frameworkPath) + '/widgets',
30 'style': path.resolve(frameworkPath) + '/style',
31 'utils': path.resolve(frameworkPath) + '/utils'
32 }
33 },
34 module: {
35 loaders: [{
36 test: /\.(jpe?g|png|gif|svg|ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/i,
37 loader: "file-loader"
38 },
39 {
40 test: /\.(js|jsx)$/,
41 exclude: /react-treeview/,
42 loader: 'babel-loader',
43 query: {
44 presets: ["es2015", "stage-0", "react"]
45 }
46 }, {
47 test: /\.css$/,
48 loader: 'style!css'
49 }, {
50 test: /\.scss/,
51 loader: 'style!css!sass?includePaths[]='+ path.resolve(frameworkPath)
52 }
53 ]
54 },
55 plugins: [
56 new HtmlWebpackPlugin({
57 filename: '../' + htmlFilename,
58 template: frameworkPath + '/plugin-index.html'
59 }),
60 ]
61 };
62
63 if (process.argv.indexOf('--optimize-minimize') !== -1) {
64 // we are going to output a gzip file in the production process
65 config.output.filename = "gzip-" + config.output.filename;
66 config.plugins.push(new webpack.DefinePlugin({ // <-- key to reducing React's size
67 'process.env': {
68 'NODE_ENV': JSON.stringify('production')
69 }
70 }));
71 config.plugins.push(new CompressionPlugin({
72 asset: "[path]", // overwrite js file with gz file
73 algorithm: "gzip",
74 test: /\.(js)$/
75 }));
76 }
77
78 module.exports = config;