2017-04-21 08:31:38 -04:00
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
const path = require('path');
|
2016-03-28 17:53:30 -04:00
|
|
|
|
2017-08-17 18:24:22 -04:00
|
|
|
// PostCss
|
|
|
|
const autoprefixer = require('autoprefixer');
|
|
|
|
const postcssVars = require('postcss-simple-vars');
|
|
|
|
|
2017-04-21 08:31:38 -04:00
|
|
|
const routes = require('./src/routes.json');
|
|
|
|
const TemplateConfig = require('./src/template-config.js');
|
2016-04-08 12:38:50 -04:00
|
|
|
|
|
|
|
// Prepare all entry points
|
2017-04-21 08:31:38 -04:00
|
|
|
const entry = {
|
2016-09-21 16:00:11 -04:00
|
|
|
// common: [
|
|
|
|
// // Vendor
|
|
|
|
// 'react',
|
|
|
|
// 'react-dom'
|
|
|
|
// ]
|
2016-09-21 13:02:23 -04:00
|
|
|
};
|
2017-04-21 08:31:38 -04:00
|
|
|
routes.forEach(route => {
|
2016-09-21 13:02:23 -04:00
|
|
|
if (!route.redirect) {
|
2017-04-21 08:31:38 -04:00
|
|
|
entry[route.name] = `./src/views/${route.name}/${route.name}.jsx`;
|
2016-09-21 13:02:23 -04:00
|
|
|
}
|
2016-04-08 12:38:50 -04:00
|
|
|
});
|
|
|
|
|
2016-03-28 17:53:30 -04:00
|
|
|
module.exports = {
|
2016-09-02 11:39:18 -04:00
|
|
|
entry: entry,
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, 'build'),
|
|
|
|
filename: 'js/[name].bundle.js'
|
|
|
|
},
|
|
|
|
module: {
|
2017-08-17 18:24:22 -04:00
|
|
|
rules: [{
|
|
|
|
test: /\.jsx?$/,
|
2016-09-02 11:39:18 -04:00
|
|
|
loader: 'babel-loader',
|
|
|
|
include: path.resolve(__dirname, 'src'),
|
2017-08-17 18:24:22 -04:00
|
|
|
options: {
|
2017-08-30 16:44:15 -04:00
|
|
|
plugins: ['transform-object-rest-spread'],
|
2016-09-02 11:39:18 -04:00
|
|
|
presets: ['es2015', 'react']
|
2016-03-28 17:53:30 -04:00
|
|
|
}
|
2017-08-17 18:24:22 -04:00
|
|
|
},
|
|
|
|
{
|
2016-09-02 11:39:18 -04:00
|
|
|
test: /\.css$/,
|
2017-08-17 18:24:22 -04:00
|
|
|
use: [{
|
|
|
|
loader: 'style-loader'
|
|
|
|
}, {
|
|
|
|
loader: 'css-loader'
|
|
|
|
}, {
|
|
|
|
loader: 'postcss-loader',
|
|
|
|
options: {
|
|
|
|
ident: 'postcss',
|
|
|
|
plugins: function () {
|
|
|
|
return [
|
|
|
|
postcssVars,
|
|
|
|
autoprefixer({
|
|
|
|
browsers: ['last 3 versions', 'Safari >= 8', 'iOS >= 8']
|
|
|
|
})
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.scss$/,
|
|
|
|
use: [{
|
|
|
|
loader: 'style-loader'
|
|
|
|
}, {
|
|
|
|
loader: 'css-loader'
|
|
|
|
}, {
|
|
|
|
loader: 'sass-loader'
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
{
|
2017-08-30 16:44:15 -04:00
|
|
|
test: /\.(png|jpg|gif|eot|svg|ttf|woff)$/i,
|
2016-09-02 11:39:18 -04:00
|
|
|
loader: 'url-loader'
|
2017-08-17 18:24:22 -04:00
|
|
|
},
|
2017-08-16 10:00:19 -04:00
|
|
|
{
|
|
|
|
test: /\.html$/,
|
|
|
|
loader: 'html-loader'
|
|
|
|
},
|
2017-08-17 18:24:22 -04:00
|
|
|
{
|
2016-09-02 11:39:18 -04:00
|
|
|
test: /\.less$/,
|
2017-08-17 18:24:22 -04:00
|
|
|
use: [
|
|
|
|
'style-loader',
|
|
|
|
'css-loader',
|
|
|
|
'less-loader'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
2016-09-02 11:39:18 -04:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new CopyWebpackPlugin([{
|
|
|
|
from: 'static'
|
|
|
|
}])
|
2016-09-21 13:02:23 -04:00
|
|
|
].concat(routes
|
2017-04-21 08:31:38 -04:00
|
|
|
.filter(route => !route.redirect)
|
|
|
|
.map(route => new HtmlWebpackPlugin(Object.assign({}, TemplateConfig, {
|
|
|
|
title: route.title,
|
|
|
|
filename: `${route.name}.html`,
|
|
|
|
route: route
|
|
|
|
})))
|
2016-09-21 13:02:23 -04:00
|
|
|
)
|
2016-09-02 11:39:18 -04:00
|
|
|
};
|