This commit is contained in:
syuilo 2018-02-16 03:23:10 +09:00
parent 085ac938c2
commit 11f32375b6
10 changed files with 70 additions and 122 deletions

View file

@ -37,7 +37,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import Sortable from 'sortablejs'; import * as Sortable from 'sortablejs';
import Autocomplete from '../../scripts/autocomplete'; import Autocomplete from '../../scripts/autocomplete';
import getKao from '../../../common/scripts/get-kao'; import getKao from '../../../common/scripts/get-kao';
import notify from '../../scripts/notify'; import notify from '../../scripts/notify';

View file

@ -7,9 +7,11 @@ function trim(text) {
module.exports = function(src) { module.exports = function(src) {
this.cacheable(); this.cacheable();
const options = loaderUtils.getOptions(this); const options = loaderUtils.getOptions(this);
if (typeof options.search != 'string' || options.search.length == 0) console.error('invalid search'); const search = options.search;
if (typeof options.replace != 'function') console.error('invalid replacer'); const replace = global[options.replace];
src = src.replace(new RegExp(trim(options.search), 'g'), options.replace); if (typeof search != 'string' || search.length == 0) console.error('invalid search');
if (typeof replace != 'function') console.error('invalid replacer:', replace, this.request);
src = src.replace(new RegExp(trim(search), 'g'), replace);
this.callback(null, src); this.callback(null, src);
return src; return src;
}; };

View file

@ -1,5 +0,0 @@
import rules from './rules';
export default lang => ({
rules: rules(lang)
});

View file

@ -1,16 +0,0 @@
/**
* Replace fontawesome symbols
*/
import { pattern, replacement } from '../../../src/common/build/fa';
export default () => ({
//enforce: 'pre',
test: /\.(vue|js|ts)$/,
exclude: /node_modules/,
loader: 'replace',
query: {
search: pattern.toString(),
replace: replacement
}
});

View file

@ -1,20 +0,0 @@
/**
* Replace i18n texts
*/
import Replacer from '../../../src/common/build/i18n';
export default lang => {
const replacer = new Replacer(lang);
return {
//enforce: 'post',
test: /\.(vue|js|ts)$/,
exclude: /node_modules/,
loader: 'replace',
query: {
search: replacer.pattern.toString(),
replace: replacer.replacement
}
};
};

View file

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

View file

@ -1,13 +0,0 @@
/**
* Stylus support
*/
export default () => ({
test: /\.styl$/,
exclude: /node_modules/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{ loader: 'stylus-loader' }
]
});

View file

@ -1,13 +0,0 @@
/**
* TypeScript
*/
export default () => ({
test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {
configFile: __dirname + '/../../../src/web/app/tsconfig.json',
appendTsSuffixTo: [/\.vue$/]
}
});

View file

@ -1,31 +0,0 @@
/**
* Vue
*/
const constants = require('../../../src/const.json');
export default () => ({
test: /\.vue$/,
exclude: /node_modules/,
use: [{
loader: 'vue-loader',
options: {
cssSourceMap: 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'
}
}]
});

View file

@ -2,12 +2,17 @@
* webpack configuration * webpack configuration
*/ */
import module_ from './module'; import I18nReplacer from '../src/common/build/i18n';
import { pattern as faPattern, replacement as faReplacement } from '../src/common/build/fa';
const constants = require('../src/const.json');
import plugins from './plugins'; import plugins from './plugins';
import langs from '../locales'; import langs from '../locales';
import version from '../src/version'; import version from '../src/version';
global['faReplacement'] = faReplacement;
module.exports = Object.keys(langs).map(lang => { module.exports = Object.keys(langs).map(lang => {
// Chunk name // Chunk name
const name = lang; const name = lang;
@ -29,10 +34,67 @@ module.exports = Object.keys(langs).map(lang => {
filename: `[name].${version}.${lang}.js` filename: `[name].${version}.${lang}.js`
}; };
const i18nReplacer = new I18nReplacer(lang);
global['i18nReplacement'] = i18nReplacer.replacement;
return { return {
name, name,
entry, entry,
module: module_(lang), module: {
rules: [{
test: /\.vue$/,
exclude: /node_modules/,
use: [{
loader: 'vue-loader',
options: {
cssSourceMap: 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'
}
}, {
loader: 'replace',
query: {
search: i18nReplacer.pattern.toString(),
replace: 'i18nReplacement'
}
}, {
loader: 'replace',
query: {
search: faPattern.toString(),
replace: 'faReplacement'
}
}]
}, {
test: /\.styl$/,
exclude: /node_modules/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{ loader: 'stylus-loader' }
]
}, {
test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {
configFile: __dirname + '/../src/web/app/tsconfig.json',
appendTsSuffixTo: [/\.vue$/]
}
}]
},
plugins: plugins(version, lang), plugins: plugins(version, lang),
output, output,
resolve: { resolve: {