|
@@ -0,0 +1,102 @@
|
|
|
|
|
+/**
|
|
|
|
|
+ * @author: Yuki Takei <yuki@weseek.co.jp>
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+const helpers = require('./helpers');
|
|
|
|
|
+const webpackMerge = require('webpack-merge'); // used to merge webpack configs
|
|
|
|
|
+const commonConfig = require('./webpack.common.js'); // the settings that are common to prod and dev
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Webpack Plugins
|
|
|
|
|
+ */
|
|
|
|
|
+const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
|
|
|
|
+const IgnorePlugin = require('webpack/lib/IgnorePlugin');
|
|
|
|
|
+const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin');
|
|
|
|
|
+const OptimizeJsPlugin = require('optimize-js-plugin');
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Webpack Constants
|
|
|
|
|
+ */
|
|
|
|
|
+const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
|
|
|
|
|
+const HOST = process.env.HOST || 'localhost';
|
|
|
|
|
+const PORT = process.env.PORT || 3000;
|
|
|
|
|
+
|
|
|
|
|
+module.exports = function (env) {
|
|
|
|
|
+ return webpackMerge(commonConfig({ env: ENV }), {
|
|
|
|
|
+ devtool: 'source-map',
|
|
|
|
|
+ output: {
|
|
|
|
|
+ path: helpers.root('public/js'),
|
|
|
|
|
+ filename: '[name].[chunkhash].bundle.js',
|
|
|
|
|
+ sourceMapFilename: '[name].[chunkhash].bundle.map',
|
|
|
|
|
+ chunkFilename: '[id].[chunkhash].chunk.js'
|
|
|
|
|
+ },
|
|
|
|
|
+ module: {
|
|
|
|
|
+ rules: [
|
|
|
|
|
+ /*
|
|
|
|
|
+ * to string and css loader support for *.css files (from Angular components)
|
|
|
|
|
+ * Returns file content as string
|
|
|
|
|
+ */
|
|
|
|
|
+ {
|
|
|
|
|
+ test: /\.css$/,
|
|
|
|
|
+ use: ['to-string-loader', 'css-loader'],
|
|
|
|
|
+ include: [helpers.root('resource')]
|
|
|
|
|
+ },
|
|
|
|
|
+ /*
|
|
|
|
|
+ * to string and sass loader support for *.scss files (from Angular components)
|
|
|
|
|
+ * Returns compiled css content as string
|
|
|
|
|
+ */
|
|
|
|
|
+ {
|
|
|
|
|
+ test: /\.scss$/,
|
|
|
|
|
+ use: ['to-string-loader', 'css-loader', 'sass-loader'],
|
|
|
|
|
+ include: [helpers.root('resource')]
|
|
|
|
|
+ },
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ plugins: [
|
|
|
|
|
+
|
|
|
|
|
+ new OptimizeJsPlugin({
|
|
|
|
|
+ sourceMap: false
|
|
|
|
|
+ }),
|
|
|
|
|
+
|
|
|
|
|
+ new UglifyJsPlugin({
|
|
|
|
|
+ // beautify: true, //debug
|
|
|
|
|
+ // mangle: false, //debug
|
|
|
|
|
+ // dead_code: false, //debug
|
|
|
|
|
+ // unused: false, //debug
|
|
|
|
|
+ // deadCode: false, //debug
|
|
|
|
|
+ // compress: {
|
|
|
|
|
+ // screw_ie8: true,
|
|
|
|
|
+ // keep_fnames: true,
|
|
|
|
|
+ // drop_debugger: false,
|
|
|
|
|
+ // dead_code: false,
|
|
|
|
|
+ // unused: false
|
|
|
|
|
+ // }, // debug
|
|
|
|
|
+ // comments: true, //debug
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ beautify: false, //prod
|
|
|
|
|
+ output: {
|
|
|
|
|
+ comments: false
|
|
|
|
|
+ }, //prod
|
|
|
|
|
+ mangle: {
|
|
|
|
|
+ screw_ie8: true
|
|
|
|
|
+ }, //prod
|
|
|
|
|
+ compress: {
|
|
|
|
|
+ screw_ie8: true,
|
|
|
|
|
+ warnings: false,
|
|
|
|
|
+ conditionals: true,
|
|
|
|
|
+ unused: true,
|
|
|
|
|
+ comparisons: true,
|
|
|
|
|
+ sequences: true,
|
|
|
|
|
+ dead_code: true,
|
|
|
|
|
+ evaluate: true,
|
|
|
|
|
+ if_return: true,
|
|
|
|
|
+ join_vars: true,
|
|
|
|
|
+ negate_iife: false // we need this for lazy v8
|
|
|
|
|
+ },
|
|
|
|
|
+ }),
|
|
|
|
|
+
|
|
|
|
|
+ ],
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+}
|