This commit is contained in:
syuilo 2018-06-18 09:54:53 +09:00
parent a766faeae9
commit 80e5645a84
150 changed files with 305 additions and 2334 deletions

View file

@ -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');