This commit is contained in:
syuilo 2017-02-19 14:11:45 +09:00
parent 2f35c9d40a
commit 7609892c1f

View file

@ -159,7 +159,7 @@ gulp.task('build:client:scripts', () => new Promise(async (ok) => {
const StringReplacePlugin = require('string-replace-webpack-plugin'); const StringReplacePlugin = require('string-replace-webpack-plugin');
/* webpack options */ /* webpack options */
const pack = { const pack: Webpack.Configuration = {
entry: { entry: {
'client': './src/web/app/client/script.js', 'client': './src/web/app/client/script.js',
'desktop': './src/web/app/desktop/script.js', 'desktop': './src/web/app/desktop/script.js',
@ -170,22 +170,14 @@ gulp.task('build:client:scripts', () => new Promise(async (ok) => {
module: { module: {
preLoaders: [ preLoaders: [
{ {
test: /\.(tag|js|styl)$/, test: /\.tag$/,
exclude: /node_modules/, exclude: /node_modules/,
loader: StringReplacePlugin.replace({ loader: StringReplacePlugin.replace({
replacements: [ replacements: [
{ pattern: /VERSION/g, replacement: () => `'${commit ? commit.hash : 'null'}'` },
{ pattern: /\$theme\-color\-foreground/g, replacement: () => '#fff' }, { pattern: /\$theme\-color\-foreground/g, replacement: () => '#fff' },
{ pattern: /\$theme\-color/g, replacement: () => config.themeColor }, { pattern: /\$theme\-color/g, replacement: () => config.themeColor },
{ pattern: /CONFIG\.theme\-color/g, replacement: () => `'${config.themeColor}'` }, ]
{ pattern: /CONFIG\.themeColor/g, replacement: () => `'${config.themeColor}'` }, })
{ pattern: /CONFIG\.api\.url/g, replacement: () => `'${config.api_url}'` },
{ pattern: /CONFIG\.urls\.about/g, replacement: () => `'${config.about_url}'` },
{ pattern: /CONFIG\.urls\.dev/g, replacement: () => `'${config.dev_url}'` },
{ pattern: /CONFIG\.url/g, replacement: () => `'${config.url}'` },
{ pattern: /CONFIG\.host/g, replacement: () => `'${config.host}'` },
{ pattern: /CONFIG\.recaptcha\.siteKey/g, replacement: () => `'${config.recaptcha.siteKey}'` },
]})
}, },
], ],
loaders: [ loaders: [
@ -208,12 +200,27 @@ gulp.task('build:client:scripts', () => new Promise(async (ok) => {
}, },
{ {
test: /\.styl$/, test: /\.styl$/,
exclude: /node_modules/,
loaders: ['style', 'css', 'stylus'] loaders: ['style', 'css', 'stylus']
} }
] ]
}, },
plugins: [ plugins: [
new StringReplacePlugin() new Webpack.DefinePlugin({
VERSION: JSON.stringify(commit ? commit.hash : null),
CONFIG: {
themeColor: JSON.stringify(config.themeColor),
apiUrl: JSON.stringify(config.api_url),
aboutUrl: JSON.stringify(config.about_url),
devUrl: JSON.stringify(config.dev_url),
host: JSON.stringify(config.host),
url: JSON.stringify(config.url),
recaptcha: {
siteKey: JSON.stringify(config.recaptcha.siteKey),
}
}
}),
new StringReplacePlugin(),
], ],
output: { output: {
filename: '[name]/script.js' filename: '[name]/script.js'