Skip to content
Snippets Groups Projects
Commit 11f32375 authored by syuilo's avatar syuilo
Browse files

wip

parent 085ac938
No related branches found
No related tags found
No related merge requests found
......@@ -37,7 +37,7 @@
<script lang="ts">
import Vue from 'vue';
import Sortable from 'sortablejs';
import * as Sortable from 'sortablejs';
import Autocomplete from '../../scripts/autocomplete';
import getKao from '../../../common/scripts/get-kao';
import notify from '../../scripts/notify';
......
......@@ -7,9 +7,11 @@ function trim(text) {
module.exports = function(src) {
this.cacheable();
const options = loaderUtils.getOptions(this);
if (typeof options.search != 'string' || options.search.length == 0) console.error('invalid search');
if (typeof options.replace != 'function') console.error('invalid replacer');
src = src.replace(new RegExp(trim(options.search), 'g'), options.replace);
const search = options.search;
const replace = global[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);
return src;
};
import rules from './rules';
export default lang => ({
rules: rules(lang)
});
/**
* 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
}
});
/**
* 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
}
};
};
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()
];
/**
* Stylus support
*/
export default () => ({
test: /\.styl$/,
exclude: /node_modules/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{ loader: 'stylus-loader' }
]
});
/**
* TypeScript
*/
export default () => ({
test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {
configFile: __dirname + '/../../../src/web/app/tsconfig.json',
appendTsSuffixTo: [/\.vue$/]
}
});
/**
* 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'
}
}]
});
......@@ -2,12 +2,17 @@
* 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 langs from '../locales';
import version from '../src/version';
global['faReplacement'] = faReplacement;
module.exports = Object.keys(langs).map(lang => {
// Chunk name
const name = lang;
......@@ -29,10 +34,67 @@ module.exports = Object.keys(langs).map(lang => {
filename: `[name].${version}.${lang}.js`
};
const i18nReplacer = new I18nReplacer(lang);
global['i18nReplacement'] = i18nReplacer.replacement;
return {
name,
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),
output,
resolve: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment