2016-10-20 04:14:26 +03:00
|
|
|
const path = require('path');
|
2016-12-05 22:11:55 +02:00
|
|
|
const fs = require('fs');
|
2016-10-20 04:14:26 +03:00
|
|
|
|
2016-12-05 22:11:55 +02:00
|
|
|
const plugins = require('./plugins');
|
2016-12-12 18:27:33 +02:00
|
|
|
const paths = require('./paths');
|
|
|
|
|
|
|
|
const {
|
|
|
|
ROOT,
|
|
|
|
MODULES,
|
|
|
|
FRONTEND,
|
|
|
|
UI,
|
|
|
|
STATIC
|
|
|
|
} = paths;
|
2016-10-24 14:23:05 +03:00
|
|
|
|
2016-12-05 22:11:55 +02:00
|
|
|
module.exports = {
|
2016-12-12 18:27:33 +02:00
|
|
|
context: ROOT,
|
|
|
|
entry: `./${path.relative(ROOT, path.join(FRONTEND, 'index.js'))}`,
|
2016-12-05 22:11:55 +02:00
|
|
|
resolve: {
|
2016-12-12 18:27:33 +02:00
|
|
|
modules: MODULES,
|
|
|
|
alias: fs.readdirSync(FRONTEND)
|
|
|
|
.map((name) => path.join(FRONTEND, name))
|
2016-12-05 22:11:55 +02:00
|
|
|
.filter((fullpath) => fs.statSync(fullpath).isDirectory())
|
|
|
|
.reduce((aliases, fullpath) => Object.assign(aliases, {
|
|
|
|
[`@${path.basename(fullpath)}`]: fullpath
|
|
|
|
}), {
|
2016-12-12 18:27:33 +02:00
|
|
|
'@root': FRONTEND,
|
|
|
|
'@ui': UI
|
2016-12-05 22:11:55 +02:00
|
|
|
})
|
|
|
|
},
|
2016-12-12 18:27:33 +02:00
|
|
|
resolveLoader: {
|
|
|
|
modules: MODULES
|
|
|
|
},
|
2016-10-20 04:14:26 +03:00
|
|
|
output: {
|
2017-02-07 17:52:24 +02:00
|
|
|
pathinfo: true,
|
2016-12-05 22:11:55 +02:00
|
|
|
path: STATIC,
|
2016-10-20 04:14:26 +03:00
|
|
|
publicPath: '/static/',
|
2016-12-12 12:56:48 +02:00
|
|
|
filename: '[name].js'
|
2016-10-20 04:14:26 +03:00
|
|
|
},
|
|
|
|
plugins: [
|
2017-02-09 00:25:57 +02:00
|
|
|
plugins['no-errors'](),
|
|
|
|
plugins['define'](),
|
|
|
|
plugins['shell']()
|
2016-10-20 04:14:26 +03:00
|
|
|
],
|
|
|
|
module: {
|
2017-02-07 17:52:24 +02:00
|
|
|
rules: [{
|
2016-10-20 04:14:26 +03:00
|
|
|
test: /js?$/,
|
2017-02-07 17:52:24 +02:00
|
|
|
enforce: 'pre',
|
|
|
|
use: [{
|
2017-02-08 23:47:25 +02:00
|
|
|
loader: 'eslint-loader',
|
|
|
|
options: {
|
|
|
|
presets: [
|
|
|
|
'react-app'
|
|
|
|
]
|
|
|
|
}
|
2017-02-07 17:52:24 +02:00
|
|
|
}],
|
2016-12-12 18:27:33 +02:00
|
|
|
include: [
|
|
|
|
FRONTEND,
|
|
|
|
UI
|
2017-01-18 12:33:16 +02:00
|
|
|
]
|
2016-10-20 04:14:26 +03:00
|
|
|
}, {
|
2017-02-07 17:52:24 +02:00
|
|
|
exclude: [
|
|
|
|
/\.html$/,
|
|
|
|
/\.(js|jsx)$/,
|
|
|
|
/\.css$/,
|
|
|
|
/\.json$/,
|
|
|
|
/\.svg$/,
|
|
|
|
/\.(eot|svg|ttf|woff|woff2)$/
|
|
|
|
],
|
|
|
|
loader: 'url-loader',
|
2016-12-12 18:27:33 +02:00
|
|
|
include: [
|
|
|
|
FRONTEND,
|
|
|
|
UI
|
|
|
|
],
|
2017-02-07 17:52:24 +02:00
|
|
|
options: {
|
|
|
|
limit: 10000
|
|
|
|
}
|
2016-12-12 18:27:33 +02:00
|
|
|
}, {
|
2017-02-07 17:52:24 +02:00
|
|
|
test: /js?$/,
|
2016-12-12 18:27:33 +02:00
|
|
|
exclude: /node_modules/,
|
|
|
|
include: [
|
|
|
|
FRONTEND,
|
|
|
|
UI
|
|
|
|
],
|
2017-02-07 17:52:24 +02:00
|
|
|
loaders: [
|
|
|
|
'babel-loader'
|
2017-01-18 12:33:16 +02:00
|
|
|
]
|
2017-02-01 17:12:17 +02:00
|
|
|
}, {
|
|
|
|
test: /\.svg/,
|
|
|
|
exclude: [
|
|
|
|
/node_modules/,
|
|
|
|
path.join(UI, 'shared', 'fonts'),
|
|
|
|
],
|
|
|
|
include: [
|
|
|
|
FRONTEND,
|
|
|
|
UI
|
|
|
|
],
|
|
|
|
loader: [
|
|
|
|
'file-loader'
|
|
|
|
]
|
|
|
|
}, {
|
2017-01-13 19:57:42 +02:00
|
|
|
test: /\.(eot|svg|ttf|woff|woff2)$/,
|
2017-01-18 12:33:16 +02:00
|
|
|
loader: 'file-loader',
|
2017-01-23 13:00:07 +02:00
|
|
|
// XXX: By commenting this out, production "BUILD=production make compile"
|
|
|
|
// will break.
|
|
|
|
//
|
|
|
|
// exclude: /node_modules/,
|
2017-01-13 19:57:42 +02:00
|
|
|
include: [
|
2017-02-01 17:12:17 +02:00
|
|
|
path.join(UI, 'shared', 'fonts')
|
2017-01-23 13:00:07 +02:00
|
|
|
],
|
2017-02-07 11:40:27 +02:00
|
|
|
}, {
|
2017-01-18 12:33:16 +02:00
|
|
|
test: /\.css$/,
|
2017-01-23 18:26:40 +02:00
|
|
|
loader: 'style-loader!css-loader'
|
2017-01-24 19:06:10 +02:00
|
|
|
// XXX: Commenting out breaks node_modules that use css
|
2017-01-23 18:26:40 +02:00
|
|
|
// i.e react-select.
|
|
|
|
|
|
|
|
// exclude: /node_modules/,
|
|
|
|
// include: [
|
|
|
|
// FRONTEND,
|
|
|
|
// UI
|
|
|
|
// ]
|
2016-10-24 12:57:21 +03:00
|
|
|
}]
|
2016-10-20 04:14:26 +03:00
|
|
|
}
|
|
|
|
};
|