joyent-portal/frontend/webpack/base.js

65 lines
1.6 KiB
JavaScript
Raw Normal View History

const ExtractTextPlugin = require('extract-text-webpack-plugin');
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');
const CONTEXT = path.join(__dirname, '../src');
const STATIC = path.join(__dirname, '../static');
const ROOT = path.join(__dirname, '../..');
2016-10-24 14:23:05 +03:00
module.exports = {
context: CONTEXT,
resolve: {
modules: [
ROOT,
'node_modules'
],
alias: fs.readdirSync(CONTEXT)
.map((name) => path.join(CONTEXT, name))
.filter((fullpath) => fs.statSync(fullpath).isDirectory())
.reduce((aliases, fullpath) => Object.assign(aliases, {
[`@${path.basename(fullpath)}`]: fullpath
}), {
'@root': CONTEXT
})
},
2016-10-20 04:14:26 +03:00
output: {
path: STATIC,
2016-10-20 04:14:26 +03:00
publicPath: '/static/',
filename: 'bundle.js'
},
plugins: [
plugins['no-errors'],
plugins['extract-text'],
plugins['loader-options'],
plugins['define'],
plugins['shell']
2016-10-20 04:14:26 +03:00
],
module: {
loaders: [{
test: /js?$/,
exclude: /node_modules/,
include: [CONTEXT],
loaders: ['babel-loader']
2016-10-20 04:14:26 +03:00
}, {
test: /\.json?$/,
exclude: /node_modules/,
include: [CONTEXT],
loaders: ['json-loader']
}, {
test: /\.css?$/,
exclude: /node_modules/,
include: [CONTEXT],
loader: ExtractTextPlugin.extract({
fallbackLoader: 'style-loader',
2016-10-26 12:51:06 +03:00
loader: [
'css-loader?',
'modules&importLoaders=1&',
'localIdentName=[name]__[local]___[hash:base64:5]!',
'postcss-loader'
].join('')
})
}]
2016-10-20 04:14:26 +03:00
}
};