p5.js-web-editor/webpack.config.prod.js

136 lines
3.2 KiB
JavaScript
Raw Normal View History

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