jormungandr-bite/webpack.config.ts

84 lines
1.7 KiB
TypeScript
Raw Normal View History

2017-02-18 23:54:19 -07:00
import * as webpack from 'webpack';
const StringReplacePlugin = require('string-replace-webpack-plugin');
2017-02-21 18:49:11 -07:00
const constants = require('./src/const.json');
2017-02-21 10:27:19 -07:00
module.exports = (commit, env) => {
2017-02-18 23:54:19 -07:00
const isProduction = env === 'production';
const pack: webpack.Configuration = {
entry: {
'desktop': './src/web/app/desktop/script.js',
'mobile': './src/web/app/mobile/script.js',
'dev': './src/web/app/dev/script.js',
'auth': './src/web/app/auth/script.js'
},
module: {
rules: [
{
enforce: 'pre',
test: /\.tag$/,
exclude: /node_modules/,
loader: StringReplacePlugin.replace({
replacements: [
2017-02-22 05:43:38 -07:00
{ pattern: /\$theme\-color\-foreground/g, replacement: () => constants.themeColorForeground },
2017-02-21 18:49:11 -07:00
{ pattern: /\$theme\-color/g, replacement: () => constants.themeColor },
2017-02-18 23:54:19 -07:00
]
})
},
{
test: /\.tag$/,
exclude: /node_modules/,
loader: 'riot-tag-loader',
query: {
hot: false,
style: 'stylus',
expr: false,
compact: true,
parserOptions: {
style: {
compress: true
}
}
}
},
{
test: /\.styl$/,
exclude: /node_modules/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader'
},
{
loader: 'stylus-loader'
}
]
}
]
},
plugins: [
new webpack.DefinePlugin({
VERSION: JSON.stringify(commit ? commit.hash : null),
CONFIG: {
2017-02-21 18:49:11 -07:00
themeColor: JSON.stringify(constants.themeColor)
2017-02-18 23:54:19 -07:00
}
}),
new StringReplacePlugin(),
],
output: {
filename: '[name]/script.js'
}
};
if (isProduction) {
// TODO.
// see https://github.com/webpack/webpack/issues/2545
//pack.plugins.push(new Webpack.optimize.UglifyJsPlugin())
}
return pack;
};