From 80e5645a84cc60d76f79c48a3d565fb66ad88643 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 18 Jun 2018 09:54:53 +0900 Subject: wip --- webpack.config.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'webpack.config.ts') diff --git a/webpack.config.ts b/webpack.config.ts index 480f5d4a7a..3c426ebb49 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -6,7 +6,7 @@ import * as fs from 'fs'; import * as webpack from 'webpack'; import chalk from 'chalk'; const { VueLoaderPlugin } = require('vue-loader'); -import jsonImporter from 'node-sass-json-importer'; +const jsonImporter = require('node-sass-json-importer'); const minifyHtml = require('html-minifier').minify; const WebpackOnBuildPlugin = require('on-build-webpack'); //const HardSourceWebpackPlugin = require('hard-source-webpack-plugin'); @@ -24,10 +24,17 @@ const meta = require('./package.json'); const version = meta.clientVersion; const codename = meta.codename; +declare var global: { + faReplacement: typeof faReplacement; + collapseSpacesReplacement: any; + base64replacement: any; + i18nReplacement: typeof i18nReplacement; +}; + //#region Replacer definitions global['faReplacement'] = faReplacement; -global['collapseSpacesReplacement'] = html => { +global['collapseSpacesReplacement'] = (html: string) => { return minifyHtml(html, { collapseWhitespace: true, collapseInlineTagWhitespace: true, @@ -35,7 +42,7 @@ global['collapseSpacesReplacement'] = html => { }).replace(/\t/g, ''); }; -global['base64replacement'] = (_, key) => { +global['base64replacement'] = (_: any, key: string) => { return fs.readFileSync(__dirname + '/src/client/' + key, 'base64'); }; @@ -89,10 +96,10 @@ const consts = { _WELCOME_BG_URL_: config.welcome_bg_url }; -const _consts = {}; +const _consts: { [ key: string ]: any } = {}; Object.keys(consts).forEach(key => { - _consts[key] = JSON.stringify(consts[key]); + _consts[key] = JSON.stringify((consts as any)[key]); }); //#endregion @@ -106,7 +113,7 @@ const plugins = [ new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development') }), - new WebpackOnBuildPlugin(stats => { + new WebpackOnBuildPlugin((stats: any) => { fs.writeFileSync('./built/client/meta.json', JSON.stringify({ version }), 'utf-8'); -- cgit v1.2.3-freya