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

169 lines
3.6 KiB
JavaScript

const webpack = require('webpack');
const path = require('path');
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") {
require('dotenv').config();
}
module.exports = [{
devtool: 'source-map',
entry: {
app: [
'babel-polyfill',
path.resolve(__dirname, '../client/index.jsx')
],
vendor: [
'axios',
'classnames',
'codemirror',
'csslint',
'dropzone',
'htmlhint',
'js-beautify',
'jshint',
'moment',
'react-dom',
'react-inlinesvg',
'react-redux',
'react-router',
'react',
'redux-form',
'redux-thunk',
'redux',
]
},
output: {
path: path.resolve(__dirname, '../dist/static'),
filename: '[name].[chunkhash].js',
publicPath: '/'
},
resolve: {
extensions: ['.js', '.jsx'],
modules: [
'client',
'node_modules',
]
},
module: {
loaders: [
{
test: /main\.scss$/,
exclude: /node_modules/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader!sass-loader!postcss-loader'
})
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.(svg|mp3)$/,
loader: 'file-loader'
},
{
test: /fonts\/.*\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file-loader'
},
{
test: /_console-feed.scss/,
loader: 'sass-extract-loader',
options: {
plugins: [{ plugin: 'sass-extract-js', options: { camelCase: false } }]
}
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
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',
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
options: {
postcss: () => [
postcssFocus(),
cssnext({
browsers: ['last 2 versions', 'IE > 9']
}),
cssnano({
autoprefixer: false
}),
postcssReporter({
clearMessages: true
})
]
}
})
],
},
{
entry: {
app: [
path.resolve(__dirname, '../client/utils/previewEntry.js')
]
},
target: 'web',
output: {
path: path.resolve(__dirname, '../dist/static'),
filename: 'previewScripts.js',
publicPath: '/'
},
resolve: {
extensions: ['*', '.js', '.jsx'],
modules: [
'client',
'node_modules',
],
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
}
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
]
}];