From fb70e3b1769e9d008b75585e7c3fdfa061491f4d Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 17 May 2017 00:00:56 +0900 Subject: Refactoring --- webpack/plugins/const.ts | 13 +++++++++++++ webpack/plugins/index.ts | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 webpack/plugins/const.ts create mode 100644 webpack/plugins/index.ts (limited to 'webpack/plugins') diff --git a/webpack/plugins/const.ts b/webpack/plugins/const.ts new file mode 100644 index 0000000000..ccfcb45260 --- /dev/null +++ b/webpack/plugins/const.ts @@ -0,0 +1,13 @@ +/** + * Constant Replacer + */ + +import * as webpack from 'webpack'; + +import version from '../../src/version'; +const constants = require('../../src/const.json'); + +export default () => new webpack.DefinePlugin({ + VERSION: JSON.stringify(version), + THEME_COLOR: JSON.stringify(constants.themeColor) +}); diff --git a/webpack/plugins/index.ts b/webpack/plugins/index.ts new file mode 100644 index 0000000000..0692b9f8dd --- /dev/null +++ b/webpack/plugins/index.ts @@ -0,0 +1,19 @@ +const StringReplacePlugin = require('string-replace-webpack-plugin'); + +import constant from './const'; + +const env = process.env.NODE_ENV; +const isProduction = env === 'production'; + +export default () => { + const plugins = [ + constant(), + new StringReplacePlugin() + ]; + + if (isProduction) { + //plugins.push(new webpack.optimize.UglifyJsPlugin()); + } + + return plugins; +}; -- cgit v1.2.3-freya