1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-12-27 09:28:19 +00:00
trezor-wallet/webpack/webpack.config.dev.js

113 lines
3.6 KiB
JavaScript
Raw Normal View History

2018-03-08 16:10:53 +00:00
import { TREZOR_CONNECT_FILES, TREZOR_CONNECT_HTML, SRC, PORT } from './constants';
2017-12-13 11:01:37 +00:00
import path from 'path';
import webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import CopyWebpackPlugin from 'copy-webpack-plugin';
const extractLess = new ExtractTextPlugin({
filename: './[name].[contenthash].css',
// disable: process.env.NODE_ENV === 'development'
});
module.exports = {
devtool: 'inline-source-map',
entry: {
//'index': [ `${SRC}js/index.js`, `webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000&reload=true&__webpack_public_path=http://webpack:${PORT}`]
'index': [ `${SRC}js/index.js`, `webpack-hot-middleware/client?path=/__webpack_hmr`]
},
output: {
filename: '[name].[hash].js',
path: '/',
publicPath: '/',
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: ['babel-loader']
},
{
test: /\.less$/,
loader: extractLess.extract({
use: [
{ loader: 'css-loader' },
{ loader: 'less-loader' }
],
fallback: 'style-loader'
})
},
2018-02-20 09:30:36 +00:00
{
test: /\.css$/,
loader: extractLess.extract({
use: [
{ loader: 'css-loader' }
],
fallback: 'style-loader'
})
},
2017-12-13 11:01:37 +00:00
{
test: /\.(png|gif|jpg)$/,
loader: 'file-loader?name=./images/[name].[ext]'
},
{
test: /\.(wasm)$/,
loader: 'file-loader',
query: {
name: 'js/[name].[ext]',
},
},
{
2018-02-20 09:30:36 +00:00
test: /\.json($|\?)/,
2017-12-13 11:01:37 +00:00
loader: 'json-loader'
},
{
test: /\.(ttf|eot|svg|woff|woff2)$/,
loader: 'file-loader',
query: {
2018-02-20 09:30:36 +00:00
name: './fonts/[name].[hash].[ext]',
2017-12-13 11:01:37 +00:00
},
},
]
},
resolve: {
modules: [SRC, 'node_modules'],
},
performance: {
hints: false
},
plugins: [
extractLess,
2018-02-20 09:30:36 +00:00
2017-12-13 11:01:37 +00:00
new HtmlWebpackPlugin({
chunks: ['index'],
template: `${SRC}index.html`,
filename: 'index.html',
inject: true
}),
new CopyWebpackPlugin([
2018-03-27 15:12:58 +00:00
{ from: `${TREZOR_CONNECT_FILES}config.json`, to: './data/config.json' },
2018-03-08 16:10:53 +00:00
{ from: `${TREZOR_CONNECT_FILES}coins.json`, to: './data/coins.json' },
{ from: `${TREZOR_CONNECT_FILES}releases-1.json`, to: './data/releases-1.json' },
{ from: `${TREZOR_CONNECT_FILES}latest.txt`, to: './data/latest.txt' },
{ from: `${TREZOR_CONNECT_FILES}config_signed.bin`, to: './data/config_signed.bin' },
2017-12-13 11:01:37 +00:00
// { from: `${SRC}images/favicon.png` },
// { from: `${SRC}images` },
]),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development'),
PRODUCTION: JSON.stringify(false)
2018-02-20 09:30:36 +00:00
}),
new webpack.IgnorePlugin(/node-fetch/), // for trezor-link warning
2017-12-13 11:01:37 +00:00
],
// ignoring "fs" import in fastxpub
node: {
fs: "empty"
}
}