3 * Copyright 2016 RIFT.IO Inc
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * Webpack distribution configuration
21 * This file is set up for serving the distribution version. It will be compiled to dist/ by default
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;
35 devtool
: 'source-map',
37 publicPath
: 'assets/',
38 path
: 'public/assets/',
43 entry
: [path
.resolve(__dirname
) + '/src/index.js'],
50 extensions
: ['', '.js', '.jsx', '.css', '.scss'],
51 root
: path
.resolve(frameworkPath
),
53 'widgets': path
.resolve(frameworkPath
) + '/widgets',
54 'style': path
.resolve(frameworkPath
) + '/style',
55 'utils': path
.resolve(frameworkPath
) + '/utils',
56 'styles': path
.join(process
.cwd(), './src/styles/'),
57 'libraries': path
.join(process
.cwd(), './src/libraries/'),
58 'components': path
.join(process
.cwd(), './src/components/'),
59 //'stores': '../../../src/stores/',
60 //'actions': '../../../src/actions/',
61 'helpers': path
.join(process
.cwd(), './test/helpers/')
65 noParse
: [/autoit.js/],
68 // test: /\.(js|jsx)$/,
69 // exclude: /node_modules/,
70 // loader: 'eslint-loader'
76 exclude
: /node_modules/,
77 loader
: 'babel-loader',
79 presets
: ['es2015', 'stage-0', 'react']
83 loader
: 'style-loader!css-loader'
86 loader
: 'style-loader!css-loader!sass-loader?outputStyle=expanded&includePaths[]='+ path
.resolve(frameworkPath
)
88 test
: /\.(jpe?g|png|gif|svg|ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/i,
91 { test
: /\.json$/, loader
: "json-loader" },
95 new HtmlWebpackPlugin({
96 filename
: '../index.html',
97 templateContent
: '<div id="app"></div>'
102 if (process
.argv
.indexOf('--optimize-minimize') !== -1) {
103 // we are going to output a gzip file in the production process
104 config
.output
.filename
= "gzip-" + config
.output
.filename
;
105 config
.plugins
.push(new webpack
.DefinePlugin({ // <-- key to reducing React's size
107 'NODE_ENV': JSON
.stringify('production')
110 config
.plugins
.push(new CompressionPlugin({
111 asset
: "[path]", // overwrite js file with gz file
117 module
.exports
= config
;