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

181 lines
3.8 KiB
JavaScript
Raw Normal View History

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") {
2018-06-07 23:49:17 +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
entry: {
app: [
'babel-polyfill',
path.resolve(__dirname, '../client/index.jsx')
],
vendor: [
2016-11-30 19:37:07 +01:00
'axios',
'classnames',
'codemirror',
2016-12-13 23:17:48 +01:00
'csslint',
'dropzone',
2016-12-13 23:17:48 +01:00
'htmlhint',
'js-beautify',
'jshint',
'moment',
'react-dom',
'react-inlinesvg',
'react-redux',
'react-router',
'react',
'redux-form',
'redux-thunk',
'redux',
]
},
2016-06-28 00:46:08 +02:00
output: {
path: path.resolve(__dirname, '../dist/static'),
filename: '[name].[chunkhash].js',
publicPath: '/'
2016-06-28 00:46:08 +02:00
},
resolve: {
extensions: ['.js', '.jsx'],
modules: [
'client',
'node_modules',
]
2016-06-28 00:46:08 +02:00
},
module: {
rules: [
2016-06-28 00:46:08 +02:00
{
test: /main\.scss$/,
2016-06-28 00:46:08 +02:00
exclude: /node_modules/,
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/,
use: 'babel-loader'
2016-06-28 00:46:08 +02:00
},
{
test: /\.(svg|mp3)$/,
use: 'file-loader'
},
{
test: /\.(png)$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'images/'
}
}
2016-08-19 19:13:17 +02:00
},
{
test: /fonts\/.*\.(eot|svg|ttf|woff|woff2)$/,
use: 'file-loader'
2018-05-15 21:10:24 +02:00
},
{
test: /_console-feed.scss/,
use: {
loader: 'sass-extract-loader',
options: {
plugins: [{ plugin: 'sass-extract-js', options: { camelCase: false } }]
}
}
2016-06-28 00:46:08 +02:00
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
2016-06-28 00:46:08 +02: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-23 00:56:54 +02:00
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
2016-10-18 18:59:54 +02:00
compress: {
2016-07-23 00:56:54 +02:00
warnings: false
}
}),
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
],
},
{
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
}
})
]
2018-08-20 18:20:41 +02:00
}];