2016-08-10 05:15:44 +00:00
|
|
|
require('es6-promise').polyfill();
|
|
|
|
|
|
|
|
var path = require('path');
|
|
|
|
var webpack = require('webpack');
|
|
|
|
var autoprefixer = require('autoprefixer');
|
|
|
|
var precss = require('precss');
|
|
|
|
var functions = require('postcss-functions');
|
|
|
|
var ExtractTextPlugin = require("extract-text-webpack-plugin");
|
|
|
|
|
|
|
|
var postCssLoader = [
|
|
|
|
'css-loader?module',
|
|
|
|
'&localIdentName=[name]__[local]___[hash:base64:5]',
|
|
|
|
'&disableStructuralMinification',
|
|
|
|
'!postcss-loader'
|
|
|
|
];
|
|
|
|
|
|
|
|
var plugins = [
|
|
|
|
new webpack.NoErrorsPlugin(),
|
|
|
|
new webpack.optimize.DedupePlugin(),
|
|
|
|
new ExtractTextPlugin('bundle.css'),
|
|
|
|
];
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV === 'production') {
|
|
|
|
plugins = plugins.concat([
|
|
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
|
|
output: {comments: false},
|
|
|
|
test: /bundle\.js?$/
|
|
|
|
}),
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env': {NODE_ENV: JSON.stringify('production')}
|
|
|
|
})
|
|
|
|
]);
|
|
|
|
|
|
|
|
postCssLoader.splice(1, 1) // drop human readable names
|
|
|
|
};
|
|
|
|
|
2016-09-05 21:58:49 +00:00
|
|
|
var repo = __dirname
|
2016-08-10 15:31:27 +00:00
|
|
|
|
2016-08-10 05:15:44 +00:00
|
|
|
var config = {
|
|
|
|
entry: {
|
2016-08-10 15:31:27 +00:00
|
|
|
bundle: path.join(repo, 'frontend/index.js')
|
2016-08-10 05:15:44 +00:00
|
|
|
},
|
|
|
|
output: {
|
2016-08-10 15:31:27 +00:00
|
|
|
path: path.join(repo, 'build'),
|
2016-08-10 05:15:44 +00:00
|
|
|
publicPath: "/assets/",
|
|
|
|
filename: '[name].js'
|
|
|
|
},
|
|
|
|
plugins: plugins,
|
|
|
|
module: {
|
|
|
|
loaders: [
|
|
|
|
{test: /\.css/, loader: ExtractTextPlugin.extract('style-loader', postCssLoader.join(''))},
|
|
|
|
{test: /\.(png|gif)$/, loader: 'url-loader?name=[name]@[hash].[ext]&limit=5000'},
|
|
|
|
{test: /\.svg$/, loader: 'url-loader?name=[name]@[hash].[ext]&limit=5000!svgo-loader?useConfig=svgo1'},
|
|
|
|
{test: /\.(pdf|ico|jpg|eot|otf|woff|ttf|mp4|webm)$/, loader: 'file-loader?name=[name]@[hash].[ext]'},
|
|
|
|
{test: /\.json$/, loader: 'json-loader'},
|
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
2016-08-10 15:31:27 +00:00
|
|
|
include: path.join(repo, 'frontend'),
|
2016-08-10 05:15:44 +00:00
|
|
|
loaders: ['babel']
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['', '.js', '.jsx', '.css'],
|
|
|
|
alias: {
|
2016-08-10 15:31:27 +00:00
|
|
|
'#app': path.join(repo, 'frontend'),
|
2016-08-12 19:20:29 +00:00
|
|
|
'#components': path.join(repo, 'frontend/components'),
|
2016-08-10 15:31:27 +00:00
|
|
|
'#css': path.join(repo, 'frontend/css')
|
2016-08-10 05:15:44 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
svgo1: {
|
|
|
|
multipass: true,
|
|
|
|
plugins: [
|
|
|
|
// by default enabled
|
|
|
|
{mergePaths: false},
|
|
|
|
{convertTransform: false},
|
|
|
|
{convertShapeToPath: false},
|
|
|
|
{cleanupIDs: false},
|
|
|
|
{collapseGroups: false},
|
|
|
|
{transformsWithOnePath: false},
|
|
|
|
{cleanupNumericValues: false},
|
|
|
|
{convertPathData: false},
|
|
|
|
{moveGroupAttrsToElems: false},
|
|
|
|
// by default disabled
|
|
|
|
{removeTitle: true},
|
|
|
|
{removeDesc: true}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
postcss: function() {
|
|
|
|
return [autoprefixer, precss({
|
|
|
|
variables: {
|
2016-08-10 15:31:27 +00:00
|
|
|
variables: require(path.join(repo, 'frontend/css/vars'))
|
2016-08-10 05:15:44 +00:00
|
|
|
}
|
|
|
|
}), functions({
|
2016-08-10 15:31:27 +00:00
|
|
|
functions: require(path.join(repo, 'frontend/css/funcs'))
|
2016-08-10 05:15:44 +00:00
|
|
|
})]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = config;
|