1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-27 18:58:08 +00:00
trezor-wallet/webpack/production.babel.js

88 lines
2.5 KiB
JavaScript
Raw Normal View History

2018-05-17 20:08:34 +00:00
import webpack from 'webpack';
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';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import packageJson from '../package.json';
2019-02-15 19:56:15 +00:00
import {
SRC, BUILD, PUBLIC, TRANSLATIONS,
} from './constants';
2018-05-17 20:08:34 +00:00
2018-09-20 11:56:24 +00:00
const gitRevisionPlugin = new GitRevisionPlugin();
2018-05-17 20:08:34 +00:00
module.exports = {
mode: 'production',
entry: {
2018-08-27 15:15:22 +00:00
index: [`${SRC}index.js`],
2018-05-17 20:08:34 +00:00
},
output: {
2018-08-27 15:15:22 +00:00
filename: '[name].[hash].js',
2018-05-17 20:08:34 +00:00
path: BUILD,
publicPath: './',
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
2018-07-30 10:47:37 +00:00
use: ['babel-loader'],
2018-05-17 20:08:34 +00:00
},
{
test: /\.(png|gif|jpg)$/,
exclude: /(node_modules)/,
loader: 'file-loader',
2019-02-05 14:06:59 +00:00
options: {
outputPath: './images',
2018-07-30 10:47:37 +00:00
name: '[name].[hash].[ext]',
},
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: {
outputPath: './fonts',
name: '[name].[hash].[ext]',
},
},
{
type: 'javascript/auto',
test: /\.json/,
2019-02-15 19:56:15 +00:00
exclude: [/(node_modules)/, TRANSLATIONS],
loader: 'file-loader',
2019-02-05 14:06:59 +00:00
options: {
outputPath: './data',
name: '[name].[hash].[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: {
alias: {
public: PUBLIC,
},
2018-05-17 20:08:34 +00:00
modules: [SRC, 'node_modules'],
},
performance: {
2018-07-30 10:47:37 +00:00
hints: false,
2018-05-17 20:08:34 +00:00
},
plugins: [
new webpack.DefinePlugin({
'process.env.BUILD': JSON.stringify(process.env.BUILD),
VERSION: JSON.stringify(packageJson.version),
2018-09-24 13:27:18 +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,
favicon: `${SRC}images/favicon.ico`,
2018-05-17 20:08:34 +00:00
}),
new CopyWebpackPlugin([
{ from: `${PUBLIC}`, to: './' },
2018-05-17 20:08:34 +00:00
]),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.NamedModulesPlugin(),
2018-07-30 10:47:37 +00:00
],
};