This commit is contained in:
syuilo 2018-02-15 23:07:19 +09:00
parent a215ef6680
commit a7601f7aa4
8 changed files with 55 additions and 70 deletions

View file

@ -157,6 +157,7 @@
"serve-favicon": "2.4.5", "serve-favicon": "2.4.5",
"sortablejs": "1.7.0", "sortablejs": "1.7.0",
"speakeasy": "2.0.0", "speakeasy": "2.0.0",
"string-replace-loader": "^1.3.0",
"string-replace-webpack-plugin": "0.1.3", "string-replace-webpack-plugin": "0.1.3",
"style-loader": "0.20.1", "style-loader": "0.20.1",
"stylus": "0.54.5", "stylus": "0.54.5",
@ -182,6 +183,7 @@
"vue-template-compiler": "^2.5.13", "vue-template-compiler": "^2.5.13",
"web-push": "3.2.5", "web-push": "3.2.5",
"webpack": "3.10.0", "webpack": "3.10.0",
"webpack-replace-loader": "^1.3.0",
"websocket": "1.0.25", "websocket": "1.0.25",
"xev": "2.0.0" "xev": "2.0.0"
} }

View file

@ -8,13 +8,11 @@ export default () => ({
enforce: 'pre', enforce: 'pre',
test: /\.(vue|js)$/, test: /\.(vue|js)$/,
exclude: /node_modules/, exclude: /node_modules/,
use: [{ loader: 'string-replace-loader',
loader: 'replace-string-loader', query: {
options: {
search: /%base64:(.+?)%/g, search: /%base64:(.+?)%/g,
replace: (_, key) => { replace: (_, key) => {
return fs.readFileSync(__dirname + '/../../../src/web/' + key, 'base64'); return fs.readFileSync(__dirname + '/../../../src/web/' + key, 'base64');
} }
} }
}]
}); });

View file

@ -1,20 +1,19 @@
import * as fs from 'fs'; import * as fs from 'fs';
const minify = require('html-minifier').minify; const minify = require('html-minifier').minify;
const StringReplacePlugin = require('string-replace-webpack-plugin');
export default () => ({ export default () => ({
enforce: 'pre', enforce: 'pre',
test: /\.vue$/, test: /\.vue$/,
exclude: /node_modules/, exclude: /node_modules/,
loader: StringReplacePlugin.replace({ loader: 'string-replace-loader',
replacements: [{ query: {
pattern: /^<template>([\s\S]+?)\r?\n<\/template>/, replacement: html => { search: /^<template>([\s\S]+?)\r?\n<\/template>/,
replace: html => {
return minify(html, { return minify(html, {
collapseWhitespace: true, collapseWhitespace: true,
collapseInlineTagWhitespace: true, collapseInlineTagWhitespace: true,
keepClosingSlash: true keepClosingSlash: true
}); });
} }
}] }
})
}); });

View file

@ -8,11 +8,9 @@ export default () => ({
enforce: 'pre', enforce: 'pre',
test: /\.(vue|js|ts)$/, test: /\.(vue|js|ts)$/,
exclude: /node_modules/, exclude: /node_modules/,
use: [{ loader: 'string-replace-loader',
loader: 'replace-string-loader', query: {
options: {
search: pattern, search: pattern,
replace: replacement replace: replacement
} }
}]
}); });

View file

@ -11,12 +11,10 @@ export default lang => {
enforce: 'pre', enforce: 'pre',
test: /\.(vue|js|ts)$/, test: /\.(vue|js|ts)$/,
exclude: /node_modules/, exclude: /node_modules/,
use: [{ loader: 'string-replace-loader',
loader: 'replace-string-loader', query: {
options: {
search: replacer.pattern, search: replacer.pattern,
replace: replacer.replacement replace: replacer.replacement
} }
}]
}; };
}; };

View file

@ -1,18 +1,16 @@
import i18n from './i18n'; import i18n from './i18n';
import fa from './fa'; import fa from './fa';
//import base64 from './base64'; //import base64 from './base64';
import themeColor from './theme-color';
import vue from './vue'; import vue from './vue';
import stylus from './stylus'; import stylus from './stylus';
import typescript from './typescript'; import typescript from './typescript';
import collapseSpaces from './collapse-spaces'; import collapseSpaces from './collapse-spaces';
export default lang => [ export default lang => [
collapseSpaces(), //collapseSpaces(),
i18n(lang), //i18n(lang),
fa(), //fa(),
//base64(), //base64(),
themeColor(),
vue(), vue(),
stylus(), stylus(),
typescript() typescript()

View file

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

View file

@ -2,12 +2,30 @@
* Vue * Vue
*/ */
const constants = require('../../../src/const.json');
export default () => ({ export default () => ({
test: /\.vue$/, test: /\.vue$/,
exclude: /node_modules/, exclude: /node_modules/,
use: [{
loader: 'vue-loader', loader: 'vue-loader',
options: { options: {
cssSourceMap: false, cssSourceMap: false,
preserveWhitespace: false preserveWhitespace: false
} }
}, {
loader: 'webpack-replace-loader',
options: {
search: '$theme-color',
replace: constants.themeColor,
attr: 'g'
}
}, {
loader: 'webpack-replace-loader',
query: {
search: '$theme-color-foreground',
replace: constants.themeColorForeground,
attr: 'g'
}
}]
}); });