2018-05-17 20:08:34 +00:00
|
|
|
import webpack from 'webpack';
|
2019-04-25 11:30:04 +00:00
|
|
|
import path from 'path';
|
2018-09-20 11:56:24 +00:00
|
|
|
import GitRevisionPlugin from 'git-revision-webpack-plugin';
|
2018-05-17 20:08:34 +00:00
|
|
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
2018-09-21 10:00:12 +00:00
|
|
|
import WebpackBuildNotifierPlugin from 'webpack-build-notifier';
|
2019-02-19 20:48:48 +00:00
|
|
|
import packageJson from '../package.json';
|
2018-09-05 13:52:03 +00:00
|
|
|
|
2019-03-04 12:33:02 +00:00
|
|
|
import { SRC, BUILD, PORT, PUBLIC, TRANSLATIONS } from './constants';
|
2018-05-17 20:08:34 +00:00
|
|
|
|
2019-02-19 20:48:48 +00:00
|
|
|
// turn on for bundle analyzing
|
|
|
|
// import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
|
|
|
|
|
2018-09-20 11:56:24 +00:00
|
|
|
const gitRevisionPlugin = new GitRevisionPlugin();
|
2018-09-05 13:52:03 +00:00
|
|
|
|
2018-05-17 20:08:34 +00:00
|
|
|
module.exports = {
|
|
|
|
watch: true,
|
|
|
|
mode: 'development',
|
|
|
|
devtool: 'inline-source-map',
|
|
|
|
entry: {
|
2018-08-27 15:15:22 +00:00
|
|
|
index: [`${SRC}/index.js`],
|
2018-05-17 20:08:34 +00:00
|
|
|
},
|
|
|
|
output: {
|
|
|
|
filename: '[name].[hash].js',
|
|
|
|
path: BUILD,
|
|
|
|
},
|
|
|
|
devServer: {
|
2018-09-24 13:00:23 +00:00
|
|
|
// host: '0.0.0.0',
|
2019-03-04 12:33:02 +00:00
|
|
|
contentBase: [SRC, PUBLIC],
|
2019-02-25 11:48:41 +00:00
|
|
|
stats: 'minimal',
|
2018-05-17 20:08:34 +00:00
|
|
|
hot: true,
|
|
|
|
https: false,
|
2019-02-25 11:48:41 +00:00
|
|
|
quiet: false,
|
2018-05-17 20:08:34 +00:00
|
|
|
port: PORT,
|
|
|
|
inline: true,
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
2018-09-05 13:05:57 +00:00
|
|
|
test: /\.js?$/,
|
2018-05-17 20:08:34 +00:00
|
|
|
exclude: /node_modules/,
|
2018-09-05 12:54:24 +00:00
|
|
|
use: [
|
|
|
|
'babel-loader',
|
2019-02-04 17:09:47 +00:00
|
|
|
'react-hot-loader/webpack',
|
2018-09-05 13:05:57 +00:00
|
|
|
{
|
|
|
|
loader: 'eslint-loader',
|
|
|
|
options: {
|
|
|
|
emitWarning: true,
|
|
|
|
},
|
|
|
|
},
|
2018-09-05 12:54:24 +00:00
|
|
|
{
|
|
|
|
loader: 'stylelint-custom-processor-loader',
|
|
|
|
options: {
|
2018-09-12 15:12:52 +00:00
|
|
|
emitWarning: true,
|
2018-09-05 12:54:24 +00:00
|
|
|
configPath: '.stylelintrc',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2018-05-17 20:08:34 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png|gif|jpg)$/,
|
2018-05-18 16:23:46 +00:00
|
|
|
loader: 'file-loader?name=./images/[name].[ext]',
|
2019-02-05 14:06:59 +00:00
|
|
|
options: {
|
2018-05-18 16:23:46 +00:00
|
|
|
outputPath: './images',
|
|
|
|
name: '[name].[ext]',
|
2018-07-30 10:47:37 +00:00
|
|
|
},
|
2018-05-17 20:08:34 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(ttf|eot|svg|woff|woff2)$/,
|
|
|
|
loader: 'file-loader',
|
2019-02-05 14:06:59 +00:00
|
|
|
options: {
|
2018-05-18 16:23:46 +00:00
|
|
|
outputPath: './fonts',
|
|
|
|
name: '[name].[ext]',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'javascript/auto',
|
|
|
|
test: /\.json/,
|
2019-02-06 17:01:09 +00:00
|
|
|
exclude: [/(node_modules)/, TRANSLATIONS],
|
2018-05-18 16:23:46 +00:00
|
|
|
loader: 'file-loader',
|
2019-02-05 14:06:59 +00:00
|
|
|
options: {
|
2018-05-18 16:23:46 +00:00
|
|
|
outputPath: './data',
|
|
|
|
name: '[name].[ext]',
|
2018-05-17 20:08:34 +00:00
|
|
|
},
|
|
|
|
},
|
2018-07-30 10:47:37 +00:00
|
|
|
],
|
2018-05-17 20:08:34 +00:00
|
|
|
},
|
|
|
|
resolve: {
|
2018-09-04 15:10:52 +00:00
|
|
|
alias: {
|
|
|
|
public: PUBLIC,
|
2019-04-25 11:30:04 +00:00
|
|
|
react: path.resolve('./node_modules/react'),
|
2018-09-04 15:10:52 +00:00
|
|
|
},
|
2018-05-17 20:08:34 +00:00
|
|
|
modules: [SRC, 'node_modules'],
|
2019-04-25 11:02:52 +00:00
|
|
|
symlinks: false,
|
2018-05-17 20:08:34 +00:00
|
|
|
},
|
|
|
|
performance: {
|
2018-07-30 10:47:37 +00:00
|
|
|
hints: false,
|
2018-05-17 20:08:34 +00:00
|
|
|
},
|
|
|
|
plugins: [
|
2018-09-21 10:00:12 +00:00
|
|
|
new WebpackBuildNotifierPlugin({
|
|
|
|
title: 'Trezor Wallet',
|
|
|
|
suppressSuccess: true,
|
|
|
|
}),
|
2018-09-20 11:56:24 +00:00
|
|
|
new webpack.DefinePlugin({
|
2019-02-19 20:48:48 +00:00
|
|
|
VERSION: JSON.stringify(packageJson.version),
|
2018-09-20 11:56:24 +00:00
|
|
|
COMMITHASH: JSON.stringify(gitRevisionPlugin.commithash()),
|
|
|
|
}),
|
2018-05-17 20:08:34 +00:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
chunks: ['index'],
|
|
|
|
template: `${SRC}index.html`,
|
|
|
|
filename: 'index.html',
|
2018-07-30 10:47:37 +00:00
|
|
|
inject: true,
|
2018-09-04 16:17:09 +00:00
|
|
|
favicon: `${SRC}images/favicon.ico`,
|
2018-05-17 20:08:34 +00:00
|
|
|
}),
|
2018-09-21 10:00:12 +00:00
|
|
|
// new BundleAnalyzerPlugin({
|
|
|
|
// openAnalyzer: false,
|
|
|
|
// analyzerMode: false, // turn on to generate bundle pass 'static'
|
|
|
|
// reportFilename: 'bundle-report.html',
|
|
|
|
// }),
|
2018-05-17 20:08:34 +00:00
|
|
|
new webpack.optimize.OccurrenceOrderPlugin(),
|
|
|
|
new webpack.NoEmitOnErrorsPlugin(),
|
|
|
|
new webpack.HotModuleReplacementPlugin(),
|
|
|
|
new webpack.NamedModulesPlugin(),
|
2018-07-30 10:47:37 +00:00
|
|
|
],
|
|
|
|
};
|