joyent-portal/frontend/webpack/base.js

98 lines
1.8 KiB
JavaScript
Raw Normal View History

2016-10-20 04:14:26 +03:00
const path = require('path');
const fs = require('fs');
2016-10-20 04:14:26 +03: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
module.exports = {
2016-12-12 18:27:33 +02:00
context: ROOT,
entry: `./${path.relative(ROOT, path.join(FRONTEND, 'index.js'))}`,
resolve: {
2016-12-12 18:27:33 +02:00
modules: MODULES,
alias: fs.readdirSync(FRONTEND)
.map((name) => path.join(FRONTEND, name))
.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-12 18:27:33 +02:00
resolveLoader: {
modules: MODULES
},
2016-10-20 04:14:26 +03:00
output: {
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: [
plugins['no-errors'],
plugins['define'],
plugins['shell']
2016-10-20 04:14:26 +03:00
],
module: {
loaders: [{
test: /js?$/,
exclude: /node_modules/,
2016-12-12 18:27:33 +02:00
include: [
FRONTEND,
UI
],
2016-12-14 00:09:04 +02:00
loaders: [
'babel-loader'
]
2016-10-20 04:14:26 +03:00
}, {
test: /\.json?$/,
exclude: /node_modules/,
2016-12-12 18:27:33 +02:00
include: [
FRONTEND,
UI
],
2016-12-14 00:09:04 +02:00
loaders: [
'json-loader'
]
2016-12-12 18:27:33 +02:00
}, {
2016-12-14 00:09:04 +02:00
test: /\.png/,
2016-12-12 18:27:33 +02:00
exclude: /node_modules/,
include: [
FRONTEND,
UI
],
loader: [
2016-12-14 00:09:04 +02:00
'url-loader'
]
2017-01-13 19:57:42 +02:00
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
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: [
FRONTEND,
UI
2017-01-23 13:00:07 +02:00
],
},
{
test: /\.css$/,
exclude: /node_modules/,
loaders: [ 'style-loader', 'css-loader' ],
include: [
FRONTEND,
UI
]
}]
2016-10-20 04:14:26 +03:00
}
};