2018-05-11 19:02:40 +00:00
|
|
|
import { SRC, BUILD } from './constants';
|
2017-12-13 11:01:37 +00:00
|
|
|
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: 'css/[name].[contenthash].css',
|
2018-05-11 19:02:40 +00:00
|
|
|
// disable: process.env.NODE_ENV === 'development'
|
2017-12-13 11:01:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
entry: {
|
2018-03-29 09:35:56 +00:00
|
|
|
index: ['whatwg-fetch', `${SRC}js/index.js`]
|
2017-12-13 11:01:37 +00:00
|
|
|
},
|
|
|
|
output: {
|
2018-02-20 09:30:36 +00:00
|
|
|
filename: 'js/[name].[hash].js',
|
2017-12-13 11:01:37 +00:00
|
|
|
path: BUILD
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: ['babel-loader']
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.less$/,
|
|
|
|
include: `${SRC}styles`,
|
|
|
|
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: [
|
2018-05-11 19:02:40 +00:00
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: { minimize: true }
|
|
|
|
}
|
2018-02-20 09:30:36 +00:00
|
|
|
],
|
|
|
|
fallback: 'style-loader'
|
|
|
|
})
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png|gif|jpg)$/,
|
2018-03-08 16:10:53 +00:00
|
|
|
loader: 'file-loader',
|
|
|
|
query: {
|
|
|
|
publicPath: '../',
|
|
|
|
name: 'images/[name].[hash].[ext]',
|
|
|
|
}
|
2018-02-20 09:30:36 +00:00
|
|
|
},
|
2017-12-13 11:01:37 +00:00
|
|
|
{
|
|
|
|
test: /\.(ttf|eot|svg|woff|woff2)$/,
|
2018-03-08 16:10:53 +00:00
|
|
|
// loader: 'file-loader?publicPath=../&name=fonts/[name].[hash].[ext]',
|
|
|
|
loader: 'file-loader',
|
|
|
|
query: {
|
|
|
|
publicPath: '../',
|
|
|
|
name: 'fonts/[name].[hash].[ext]',
|
|
|
|
}
|
2017-12-13 11:01:37 +00:00
|
|
|
},
|
|
|
|
{
|
2018-02-20 09:30:36 +00:00
|
|
|
test: /\.(wasm)$/,
|
|
|
|
loader: 'file-loader',
|
|
|
|
query: {
|
2018-03-08 16:10:53 +00:00
|
|
|
name: 'js/[name].[hash].[ext]',
|
2018-02-20 09:30:36 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.json$/,
|
|
|
|
loader: 'json-loader'
|
2017-12-13 11:01:37 +00:00
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
resolve: {
|
2018-05-11 19:02:40 +00:00
|
|
|
modules: [SRC, 'node_modules']
|
2017-12-13 11:01:37 +00:00
|
|
|
},
|
|
|
|
performance: {
|
|
|
|
hints: false
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
|
|
|
|
extractLess,
|
|
|
|
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: `${SRC}index.html`,
|
|
|
|
inject: 'body',
|
|
|
|
}),
|
|
|
|
|
|
|
|
new CopyWebpackPlugin([
|
|
|
|
//{from: `${SRC}/app/robots.txt`},
|
2018-02-20 09:30:36 +00:00
|
|
|
//{ from: `${SRC}js/vendor`, to: `${BUILD}js/vendor` },
|
2017-12-13 11:01:37 +00:00
|
|
|
//{ from: `${SRC}config.json` },
|
2018-03-08 16:10:53 +00:00
|
|
|
{ from: `${SRC}images/favicon.ico`, to: `${BUILD}favicon.ico` },
|
|
|
|
{ from: `${SRC}images/favicon.png`, to: `${BUILD}favicon.png` },
|
|
|
|
{ from: `${SRC}images/dashboard.png`, to: `${BUILD}images/dashboard.png` },
|
|
|
|
{ from: `${SRC}data`, to: `${BUILD}data`, cache: false },
|
2017-12-13 11:01:37 +00:00
|
|
|
]),
|
|
|
|
new webpack.optimize.OccurrenceOrderPlugin(),
|
|
|
|
new webpack.NoEmitOnErrorsPlugin(),
|
2018-02-20 09:30:36 +00:00
|
|
|
// new webpack.optimize.UglifyJsPlugin({
|
|
|
|
// compress: {
|
|
|
|
// warnings: false,
|
|
|
|
// }
|
|
|
|
// }),
|
2017-12-13 11:01:37 +00:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
|
|
PRODUCTION: JSON.stringify(false)
|
2018-02-20 09:30:36 +00:00
|
|
|
}),
|
|
|
|
new webpack.IgnorePlugin(/node-fetch/), // for trezor-link warning
|
|
|
|
],
|
|
|
|
// ignoring "fs" import in fastxpub
|
|
|
|
node: {
|
|
|
|
fs: "empty"
|
|
|
|
}
|
2017-12-13 11:01:37 +00:00
|
|
|
}
|