diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-02-27 02:51:38 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-02-27 02:51:38 +0900 |
| commit | 134be39d38ed8cbd5ed82d7bb9af2cae6eb33fd0 (patch) | |
| tree | 9f46471e0cf82562edfaf4469044a1e15d641bb6 /webpack.config.ts | |
| parent | [Client] Fix design (diff) | |
| download | misskey-134be39d38ed8cbd5ed82d7bb9af2cae6eb33fd0.tar.gz misskey-134be39d38ed8cbd5ed82d7bb9af2cae6eb33fd0.tar.bz2 misskey-134be39d38ed8cbd5ed82d7bb9af2cae6eb33fd0.zip | |
Clean up :sparkles:
Diffstat (limited to 'webpack.config.ts')
| -rw-r--r-- | webpack.config.ts | 139 |
1 files changed, 66 insertions, 73 deletions
diff --git a/webpack.config.ts b/webpack.config.ts index 9e49867539..0fdc5aec50 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -1,83 +1,76 @@ +/** + * webpack config + */ + import * as webpack from 'webpack'; const StringReplacePlugin = require('string-replace-webpack-plugin'); - const constants = require('./src/const.json'); -module.exports = (commit, env) => { - const isProduction = env === 'production'; +const env = process.env.NODE_ENV; +const isProduction = env === 'production'; - const pack: webpack.Configuration = { - entry: { - 'desktop': './src/web/app/desktop/script.js', - 'mobile': './src/web/app/mobile/script.js', - 'dev': './src/web/app/dev/script.js', - 'auth': './src/web/app/auth/script.js' - }, - module: { - rules: [ - { - enforce: 'pre', - test: /\.tag$/, - exclude: /node_modules/, - loader: StringReplacePlugin.replace({ - replacements: [ - { pattern: /\$theme\-color\-foreground/g, replacement: () => constants.themeColorForeground }, - { pattern: /\$theme\-color/g, replacement: () => constants.themeColor }, - ] - }) - }, - { - test: /\.tag$/, - exclude: /node_modules/, - loader: 'riot-tag-loader', - query: { - hot: false, - style: 'stylus', - expr: false, - compact: true, - parserOptions: { - style: { - compress: true - } +const pack: webpack.Configuration = { + entry: { + 'desktop': './src/web/app/desktop/script.js', + 'mobile': './src/web/app/mobile/script.js', + 'dev': './src/web/app/dev/script.js', + 'auth': './src/web/app/auth/script.js' + }, + module: { + rules: [ + { + enforce: 'pre', + test: /\.tag$/, + exclude: /node_modules/, + loader: StringReplacePlugin.replace({ + replacements: [ + { pattern: /\$theme\-color\-foreground/g, replacement: () => constants.themeColorForeground }, + { pattern: /\$theme\-color/g, replacement: () => constants.themeColor }, + ] + }) + }, + { + test: /\.tag$/, + exclude: /node_modules/, + loader: 'riot-tag-loader', + query: { + hot: false, + style: 'stylus', + expr: false, + compact: true, + parserOptions: { + style: { + compress: true } } - }, - { - test: /\.styl$/, - exclude: /node_modules/, - use: [ - { - loader: 'style-loader' - }, - { - loader: 'css-loader' - }, - { - loader: 'stylus-loader' - } - ] } - ] - }, - plugins: [ - new webpack.DefinePlugin({ - VERSION: JSON.stringify(commit ? commit.hash : null), - CONFIG: { - themeColor: JSON.stringify(constants.themeColor) - } - }), - new StringReplacePlugin(), - ], - output: { - filename: '[name]/script.js' - } - }; - - if (isProduction) { - // TODO. - // see https://github.com/webpack/webpack/issues/2545 - //pack.plugins.push(new Webpack.optimize.UglifyJsPlugin()) + }, + { + test: /\.styl$/, + exclude: /node_modules/, + use: [ + { loader: 'style-loader' }, + { loader: 'css-loader' }, + { loader: 'stylus-loader' } + ] + } + ] + }, + plugins: [ + new webpack.DefinePlugin({ + CONFIG: { + themeColor: JSON.stringify(constants.themeColor) + } + }), + new StringReplacePlugin() + ], + output: { + filename: '[name]/script.js' } - - return pack; }; + +if (isProduction) { + pack.plugins.push(new webpack.optimize.UglifyJsPlugin()); +} + +module.exports = pack; |