2018-02-26 20:50:13 +01:00
|
|
|
const webpack = require('webpack');
|
|
|
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
|
|
|
const ManifestPlugin = require('webpack-manifest-plugin');
|
|
|
|
const ChunkManifestPlugin = require('chunk-manifest-webpack-plugin');
|
|
|
|
const cssnext = require('postcss-cssnext');
|
|
|
|
const postcssFocus = require('postcss-focus');
|
|
|
|
const postcssReporter = require('postcss-reporter');
|
|
|
|
const cssnano = require('cssnano');
|
2016-07-21 02:59:37 +02:00
|
|
|
require('dotenv').config();
|
2016-06-28 00:46:08 +02:00
|
|
|
|
|
|
|
module.exports = {
|
2017-05-18 23:41:25 +02:00
|
|
|
devtool: 'source-map',
|
2016-06-28 20:41:15 +02:00
|
|
|
|
2016-11-09 00:11:12 +01:00
|
|
|
entry: {
|
|
|
|
app: [
|
|
|
|
'babel-polyfill',
|
2016-11-09 00:54:54 +01:00
|
|
|
'./client/index.jsx'
|
2016-11-09 00:11:12 +01:00
|
|
|
],
|
|
|
|
vendor: [
|
2016-11-30 19:37:07 +01:00
|
|
|
'axios',
|
|
|
|
'classnames',
|
2018-02-26 20:50:13 +01:00
|
|
|
'codemirror',
|
2016-12-13 23:17:48 +01:00
|
|
|
'csslint',
|
2018-02-26 20:50:13 +01:00
|
|
|
'dropzone',
|
2016-12-13 23:17:48 +01:00
|
|
|
'htmlhint',
|
|
|
|
'js-beautify',
|
2018-02-26 20:50:13 +01:00
|
|
|
'jshint',
|
|
|
|
'moment',
|
|
|
|
'react-dom',
|
|
|
|
'react-inlinesvg',
|
|
|
|
'react-redux',
|
|
|
|
'react-router',
|
|
|
|
'react',
|
|
|
|
'redux-form',
|
|
|
|
'redux-thunk',
|
|
|
|
'redux',
|
2016-11-09 00:11:12 +01:00
|
|
|
]
|
|
|
|
},
|
2016-06-28 00:46:08 +02:00
|
|
|
output: {
|
2018-02-26 20:50:13 +01:00
|
|
|
path: `${__dirname}/static/dist`,
|
2016-11-09 00:11:12 +01:00
|
|
|
filename: '[name].[chunkhash].js',
|
2016-06-28 00:46:08 +02:00
|
|
|
publicPath: '/dist/'
|
|
|
|
},
|
|
|
|
|
|
|
|
resolve: {
|
2017-11-06 22:19:43 +01:00
|
|
|
extensions: ['.js', '.jsx'],
|
2016-11-09 00:11:12 +01:00
|
|
|
modules: [
|
|
|
|
'client',
|
|
|
|
'node_modules',
|
|
|
|
]
|
2016-06-28 00:46:08 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
module: {
|
|
|
|
loaders: [
|
|
|
|
{
|
|
|
|
test: /\.scss$/,
|
|
|
|
exclude: /node_modules/,
|
2017-11-06 22:19:43 +01:00
|
|
|
loader: ExtractTextPlugin.extract({
|
|
|
|
fallback: 'style-loader',
|
|
|
|
use: 'css-loader!sass-loader!postcss-loader'
|
|
|
|
})
|
2016-06-28 00:46:08 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
|
|
|
exclude: /node_modules/,
|
2017-11-06 22:19:43 +01:00
|
|
|
loader: 'babel-loader'
|
2016-06-28 00:46:08 +02:00
|
|
|
},
|
|
|
|
{
|
2016-08-15 17:51:11 +02:00
|
|
|
test: /\.(svg|mp3)$/,
|
2017-11-06 22:19:43 +01:00
|
|
|
loader: 'file-loader'
|
2016-08-19 19:13:17 +02:00
|
|
|
},
|
|
|
|
{
|
2018-02-26 20:50:13 +01:00
|
|
|
test: /fonts\/.*\.(eot|svg|ttf|woff|woff2)$/,
|
|
|
|
loader: 'file-loader'
|
2016-06-28 00:46:08 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env': {
|
2018-02-26 20:50:13 +01:00
|
|
|
API_URL: process.env.API_URL ? `"${process.env.API_URL}"` : undefined,
|
|
|
|
NODE_ENV: JSON.stringify('production'),
|
|
|
|
S3_BUCKET: process.env.S3_BUCKET ? `"${process.env.S3_BUCKET}"` : undefined,
|
|
|
|
S3_BUCKET_URL_BASE: process.env.S3_BUCKET_URL_BASE ? `"${process.env.S3_BUCKET_URL_BASE}"` : undefined,
|
|
|
|
AWS_REGION: process.env.AWS_REGION ? `"${process.env.AWS_REGION}"` : undefined
|
2016-06-28 00:46:08 +02:00
|
|
|
}
|
|
|
|
}),
|
2016-11-09 00:11:12 +01:00
|
|
|
new webpack.optimize.CommonsChunkPlugin({
|
|
|
|
name: 'vendor',
|
|
|
|
minChunks: Infinity,
|
2018-02-26 20:50:13 +01:00
|
|
|
filename: '[name].[chunkhash].js',
|
2016-11-09 00:11:12 +01:00
|
|
|
}),
|
2017-11-06 22:19:43 +01:00
|
|
|
new ExtractTextPlugin({ filename: 'app.[chunkhash].css', allChunks: true }),
|
2016-11-09 00:11:12 +01:00
|
|
|
new ManifestPlugin({
|
|
|
|
basePath: '/',
|
|
|
|
}),
|
|
|
|
new ChunkManifestPlugin({
|
2018-02-26 20:50:13 +01:00
|
|
|
filename: 'chunk-manifest.json',
|
|
|
|
manifestVariable: 'webpackManifest',
|
2016-11-09 00:11:12 +01:00
|
|
|
}),
|
2016-07-23 00:56:54 +02:00
|
|
|
new webpack.optimize.UglifyJsPlugin({
|
2016-10-18 18:59:54 +02:00
|
|
|
compress: {
|
2016-07-23 00:56:54 +02:00
|
|
|
warnings: false
|
|
|
|
}
|
2017-11-06 22:19:43 +01:00
|
|
|
}),
|
|
|
|
new webpack.LoaderOptionsPlugin({
|
|
|
|
options: {
|
|
|
|
postcss: () => [
|
|
|
|
postcssFocus(),
|
|
|
|
cssnext({
|
|
|
|
browsers: ['last 2 versions', 'IE > 9']
|
|
|
|
}),
|
|
|
|
cssnano({
|
|
|
|
autoprefixer: false
|
|
|
|
}),
|
|
|
|
postcssReporter({
|
|
|
|
clearMessages: true
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}
|
2016-07-23 00:56:54 +02:00
|
|
|
})
|
2016-06-28 20:41:15 +02:00
|
|
|
],
|
|
|
|
|
2017-03-16 05:34:14 +01:00
|
|
|
};
|