Revert "BUG-410 -- update RIFT platform"
[osm/UI.git] / skyquake / plugins / composer / webpack.production.config.js
1 /*
2 *
3 * Copyright 2016 RIFT.IO Inc
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18 /*
19 * Webpack distribution configuration
20 *
21 * This file is set up for serving the distribution version. It will be compiled to dist/ by default
22 */
23
24 'use strict';
25
26 var webpack = require('webpack');
27 var path = require('path');
28 var uiPluginCmakeBuild = process.env.ui_plugin_cmake_build || false;
29 var frameworkPath = uiPluginCmakeBuild?'../../../../skyquake/skyquake-build/framework':'../../framework';
30 var HtmlWebpackPlugin = require('html-webpack-plugin');
31 var CompressionPlugin = require("compression-webpack-plugin");
32 // Added to overcome node-sass bug https://github.com/iam4x/isomorphic-flux-boilerplate/issues/62
33 process.env.UV_THREADPOOL_SIZE=64;
34 var htmlFilename = (process.argv.indexOf('--production-debug') !== -1) ? 'debug.html' : 'index.html'
35 var config = {
36 devtool: 'source-map',
37 output: {
38 publicPath: 'assets/',
39 path: 'public/assets/',
40 filename: 'bundle.js'
41 },
42
43 debug: false,
44 entry: [path.resolve(__dirname) + '/src/index.js'],
45
46 stats: {
47 colors: true,
48 reasons: false
49 },
50 resolve: {
51 extensions: ['', '.js', '.jsx', '.css', '.scss'],
52 root: path.resolve(frameworkPath),
53 alias: {
54 'widgets': path.resolve(frameworkPath) + '/widgets',
55 'style': path.resolve(frameworkPath) + '/style',
56 'utils': path.resolve(frameworkPath) + '/utils',
57 'styles': path.join(process.cwd(), './src/styles/'),
58 'libraries': path.join(process.cwd(), './src/libraries/'),
59 'components': path.join(process.cwd(), './src/components/'),
60 //'stores': '../../../src/stores/',
61 //'actions': '../../../src/actions/',
62 'helpers': path.join(process.cwd(), './test/helpers/')
63 }
64 },
65 module: {
66 noParse: [/autoit.js/],
67 // preLoaders: [
68 // {
69 // test: /\.(js|jsx)$/,
70 // exclude: /node_modules/,
71 // loader: 'eslint-loader'
72 // }
73 // ],
74 loaders: [
75 {
76 test: /\.(js|jsx)$/,
77 exclude: /node_modules/,
78 loader: 'babel-loader',
79 query: {
80 presets: ['es2015', 'stage-0', 'react']
81 }
82 }, {
83 test: /\.css$/,
84 loader: 'style-loader!css-loader'
85 }, {
86 test: /\.scss/,
87 loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded&includePaths[]='+ path.resolve(frameworkPath)
88 },{
89 test: /\.(jpe?g|png|gif|svg|ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/i,
90 loader: "file-loader"
91 },
92 { test: /\.json$/, loader: "json-loader" },
93 ]
94 },
95 plugins: [
96 new HtmlWebpackPlugin({
97 filename: '../' + htmlFilename,
98 template: frameworkPath + '/plugin-index.html'
99 })
100 ]
101 };
102
103 if (process.argv.indexOf('--optimize-minimize') !== -1) {
104 // we are going to output a gzip file in the production process
105 config.output.filename = "gzip-" + config.output.filename;
106 config.plugins.push(new webpack.DefinePlugin({ // <-- key to reducing React's size
107 'process.env': {
108 'NODE_ENV': JSON.stringify('production')
109 }
110 }));
111 config.plugins.push(new CompressionPlugin({
112 asset: "[path]", // overwrite js file with gz file
113 algorithm: "gzip",
114 test: /\.(js)$/
115 }));
116 }
117
118 module.exports = config;