2017-07-02 05:49:06 +00:00
|
|
|
'use strict';
|
|
|
|
const path = require('path');
|
|
|
|
const webpack = require('webpack');
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
|
|
const config = require('./config');
|
|
|
|
const _ = require('./utils');
|
2017-09-25 02:06:28 +00:00
|
|
|
const { CheckerPlugin } = require('awesome-typescript-loader');
|
2017-04-12 04:59:58 +00:00
|
|
|
module.exports = {
|
2017-07-02 05:49:06 +00:00
|
|
|
entry: {
|
2017-09-25 02:06:28 +00:00
|
|
|
client: './common/index.tsx'
|
2017-07-02 05:49:06 +00:00
|
|
|
},
|
|
|
|
output: {
|
|
|
|
path: _.outputPath,
|
|
|
|
filename: '[name].js',
|
|
|
|
publicPath: config.publicPath
|
|
|
|
},
|
|
|
|
performance: {
|
|
|
|
hints: process.env.NODE_ENV === 'production' ? 'warning' : false
|
|
|
|
},
|
|
|
|
resolve: {
|
2017-09-25 02:06:28 +00:00
|
|
|
extensions: ['.ts', '.tsx', '.js', '.css', '.json', '.scss', '.less'],
|
2017-07-02 05:49:06 +00:00
|
|
|
modules: [
|
|
|
|
// places where to search for required modules
|
2017-07-15 04:16:36 +00:00
|
|
|
config.srcPath,
|
2017-07-02 05:49:06 +00:00
|
|
|
_.cwd('node_modules'),
|
|
|
|
_.cwd('./')
|
|
|
|
]
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
loaders: [
|
|
|
|
{
|
2017-09-25 02:06:28 +00:00
|
|
|
test: /\.(ts|tsx)$/,
|
2017-09-14 22:49:15 +00:00
|
|
|
loaders: [
|
2017-09-25 02:06:28 +00:00
|
|
|
{ loader: 'cache-loader' },
|
2017-09-14 22:49:15 +00:00
|
|
|
{
|
2017-09-25 02:06:28 +00:00
|
|
|
loader: 'awesome-typescript-loader'
|
2017-09-14 22:49:15 +00:00
|
|
|
}
|
|
|
|
],
|
2017-09-25 02:06:28 +00:00
|
|
|
exclude: [/node_modules/]
|
2017-07-02 05:49:06 +00:00
|
|
|
},
|
|
|
|
{
|
2017-07-14 17:04:08 +00:00
|
|
|
test: /\.(gif|png|jpe?g|svg)$/i,
|
|
|
|
loaders: [
|
|
|
|
{
|
|
|
|
loader: 'file-loader',
|
|
|
|
query: {
|
|
|
|
hash: 'sha512',
|
|
|
|
digest: 'hex',
|
|
|
|
name: '[path][name].[ext]?[hash:6]'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'image-webpack-loader',
|
|
|
|
query: config.imageCompressionOptions
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(ico|eot|otf|webp|ttf|woff|woff2)(\?.*)?$/,
|
|
|
|
loader: 'file-loader?limit=100000'
|
2017-07-02 05:49:06 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env.BUILD_GH_PAGES': JSON.stringify(!!process.env.BUILD_GH_PAGES)
|
|
|
|
}),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
title: config.title,
|
|
|
|
template: path.resolve(__dirname, '../common/index.html'),
|
|
|
|
filename: _.outputIndexPath
|
|
|
|
}),
|
|
|
|
new webpack.LoaderOptionsPlugin(_.loadersOptions()),
|
|
|
|
new CopyWebpackPlugin([
|
|
|
|
{
|
|
|
|
from: _.cwd('./static'),
|
|
|
|
// to the root of dist path
|
|
|
|
to: './'
|
|
|
|
}
|
|
|
|
])
|
|
|
|
],
|
|
|
|
target: _.target
|
|
|
|
};
|