This commit is contained in:
syuilo 2018-02-15 19:59:07 +09:00
parent acfa2ef028
commit 58a6e647b3
12 changed files with 50 additions and 73 deletions

View file

@ -117,6 +117,7 @@
"gulp-typescript": "3.2.4", "gulp-typescript": "3.2.4",
"gulp-uglify": "3.0.0", "gulp-uglify": "3.0.0",
"gulp-util": "3.0.8", "gulp-util": "3.0.8",
"hard-source-webpack-plugin": "^0.5.18",
"highlight.js": "9.12.0", "highlight.js": "9.12.0",
"html-minifier": "^3.5.9", "html-minifier": "^3.5.9",
"inquirer": "5.0.1", "inquirer": "5.0.1",
@ -145,6 +146,7 @@
"recaptcha-promise": "0.1.3", "recaptcha-promise": "0.1.3",
"reconnecting-websocket": "3.2.2", "reconnecting-websocket": "3.2.2",
"redis": "2.8.0", "redis": "2.8.0",
"replace-string-loader": "0.0.7",
"request": "2.83.0", "request": "2.83.0",
"rimraf": "2.6.2", "rimraf": "2.6.2",
"riot": "3.8.1", "riot": "3.8.1",

View file

@ -3,17 +3,18 @@
*/ */
import * as fs from 'fs'; import * as fs from 'fs';
const StringReplacePlugin = require('string-replace-webpack-plugin');
export default () => ({ export default () => ({
enforce: 'pre', enforce: 'pre',
test: /\.(vue|js)$/, test: /\.(vue|js)$/,
exclude: /node_modules/, exclude: /node_modules/,
loader: StringReplacePlugin.replace({ use: [{
replacements: [{ loader: 'replace-string-loader',
pattern: /%base64:(.+?)%/g, replacement: (_, key) => { options: {
search: /%base64:(.+?)%/g,
replace: (_, key) => {
return fs.readFileSync(__dirname + '/../../../src/web/' + key, 'base64'); return fs.readFileSync(__dirname + '/../../../src/web/' + key, 'base64');
} }
}
}] }]
})
}); });

View file

@ -2,16 +2,17 @@
* Replace fontawesome symbols * Replace fontawesome symbols
*/ */
const StringReplacePlugin = require('string-replace-webpack-plugin');
import { pattern, replacement } from '../../../src/common/build/fa'; import { pattern, replacement } from '../../../src/common/build/fa';
export default () => ({ export default () => ({
enforce: 'pre', enforce: 'pre',
test: /\.(vue|js|ts)$/, test: /\.(vue|js|ts)$/,
exclude: /node_modules/, exclude: /node_modules/,
loader: StringReplacePlugin.replace({ use: [{
replacements: [{ loader: 'replace-string-loader',
pattern, replacement options: {
search: pattern,
replace: replacement
}
}] }]
})
}); });

View file

@ -2,7 +2,6 @@
* Replace i18n texts * Replace i18n texts
*/ */
const StringReplacePlugin = require('string-replace-webpack-plugin');
import Replacer from '../../../src/common/build/i18n'; import Replacer from '../../../src/common/build/i18n';
export default lang => { export default lang => {
@ -12,10 +11,12 @@ export default lang => {
enforce: 'pre', enforce: 'pre',
test: /\.(vue|js|ts)$/, test: /\.(vue|js|ts)$/,
exclude: /node_modules/, exclude: /node_modules/,
loader: StringReplacePlugin.replace({ use: [{
replacements: [{ loader: 'replace-string-loader',
pattern: replacer.pattern, replacement: replacer.replacement options: {
search: replacer.pattern,
replace: replacer.replacement
}
}] }]
})
}; };
}; };

View file

@ -1,7 +1,6 @@
import i18n from './i18n'; import i18n from './i18n';
import license from './license';
import fa from './fa'; import fa from './fa';
import base64 from './base64'; //import base64 from './base64';
import themeColor from './theme-color'; import themeColor from './theme-color';
import vue from './vue'; import vue from './vue';
import stylus from './stylus'; import stylus from './stylus';
@ -11,9 +10,8 @@ import collapseSpaces from './collapse-spaces';
export default lang => [ export default lang => [
collapseSpaces(), collapseSpaces(),
i18n(lang), i18n(lang),
license(),
fa(), fa(),
base64(), //base64(),
themeColor(), themeColor(),
vue(), vue(),
stylus(), stylus(),

View file

@ -1,17 +0,0 @@
/**
* Inject license
*/
const StringReplacePlugin = require('string-replace-webpack-plugin');
import { licenseHtml } from '../../../src/common/build/license';
export default () => ({
enforce: 'pre',
test: /\.(vue|js)$/,
exclude: /node_modules/,
loader: StringReplacePlugin.replace({
replacements: [{
pattern: '%license%', replacement: () => licenseHtml
}]
})
});

View file

@ -2,24 +2,24 @@
* Theme color provider * Theme color provider
*/ */
const StringReplacePlugin = require('string-replace-webpack-plugin');
const constants = require('../../../src/const.json'); const constants = require('../../../src/const.json');
export default () => ({ export default () => ({
enforce: 'pre', enforce: 'pre',
test: /\.vue$/, test: /\.vue$/,
exclude: /node_modules/, exclude: /node_modules/,
loader: StringReplacePlugin.replace({ use: [/*{
replacements: [ loader: 'replace-string-loader',
{ options: {
pattern: /\$theme\-color\-foreground/g, search: /\$theme\-color\-foreground/g,
replacement: () => constants.themeColorForeground replace: constants.themeColorForeground
}, }
{ }, */{
pattern: /\$theme\-color/g, loader: 'replace-string-loader',
replacement: () => constants.themeColor options: {
}, search: '$theme-color',
] replace: constants.themeColor,
}) flags: 'g'
}
}]
}); });

View file

@ -4,6 +4,7 @@
export default () => ({ export default () => ({
test: /\.ts$/, test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts-loader', loader: 'ts-loader',
options: { options: {
configFile: __dirname + '/../../../src/web/app/tsconfig.json', configFile: __dirname + '/../../../src/web/app/tsconfig.json',

View file

@ -1,10 +0,0 @@
import * as os from 'os';
import * as webpack from 'webpack';
export default version => new webpack.BannerPlugin({
banner:
`Misskey v${version} | MIT Licensed, (c) syuilo 2014-2018\n` +
'https://github.com/syuilo/misskey\n' +
`built by ${os.hostname()} at ${new Date()}\n` +
'hash:[hash], chunkhash:[chunkhash]'
});

View file

@ -7,6 +7,7 @@ import * as webpack from 'webpack';
import version from '../../src/version'; import version from '../../src/version';
const constants = require('../../src/const.json'); const constants = require('../../src/const.json');
import config from '../../src/conf'; import config from '../../src/conf';
import { licenseHtml } from '../../src/common/build/license';
export default lang => { export default lang => {
const consts = { const consts = {
@ -24,6 +25,7 @@ export default lang => {
_LANG_: lang, _LANG_: lang,
_HOST_: config.host, _HOST_: config.host,
_URL_: config.url, _URL_: config.url,
_LICENSE_: licenseHtml
}; };
const _consts = {}; const _consts = {};
@ -32,7 +34,5 @@ export default lang => {
_consts[key] = JSON.stringify(consts[key]); _consts[key] = JSON.stringify(consts[key]);
}); });
return new webpack.DefinePlugin(Object.assign({}, _consts, { return new webpack.DefinePlugin(_consts);
__CONSTS__: JSON.stringify(consts)
}));
}; };

View file

@ -1,17 +1,16 @@
const StringReplacePlugin = require('string-replace-webpack-plugin'); const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
import consts from './consts'; import consts from './consts';
import hoist from './hoist'; import hoist from './hoist';
import minify from './minify'; import minify from './minify';
import banner from './banner';
const env = process.env.NODE_ENV; const env = process.env.NODE_ENV;
const isProduction = env === 'production'; const isProduction = env === 'production';
export default (version, lang) => { export default (version, lang) => {
const plugins = [ const plugins = [
consts(lang), new HardSourceWebpackPlugin(),
new StringReplacePlugin() consts(lang)
]; ];
if (isProduction) { if (isProduction) {
@ -19,7 +18,5 @@ export default (version, lang) => {
plugins.push(minify()); plugins.push(minify());
} }
plugins.push(banner(version));
return plugins; return plugins;
}; };

View file

@ -40,6 +40,9 @@ module.exports = Object.keys(langs).map(lang => {
'.js', '.ts' '.js', '.ts'
] ]
}, },
cache: true cache: true,
devtool: 'eval',
stats: true,
profile: true
}; };
}); });