strapi/public/internals/webpack/webpack.prod.babel.js

67 lines
2.1 KiB
JavaScript
Raw Normal View History

2016-08-18 11:41:13 +02:00
// Important modules this config uses
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
2016-10-05 18:13:02 +02:00
const pkg = require(path.resolve(process.cwd(), 'package.json'));
const pluginId = pkg.name.replace(/^strapi-/i, '');
2016-08-18 11:41:13 +02:00
// PostCSS plugins
const cssnext = require('postcss-cssnext');
const postcssFocus = require('postcss-focus');
const postcssReporter = require('postcss-reporter');
module.exports = require('./webpack.base.babel')({
// In production, we skip all hot-reloading stuff
entry: [
path.join(process.cwd(), 'app/app.js'),
],
// Utilize long-term caching by adding content hashes (not compilation hashes) to compiled assets
output: {
2016-08-31 12:24:16 +02:00
filename: '[name].js',
2016-08-18 11:41:13 +02:00
chunkFilename: '[name].[chunkhash].chunk.js',
2016-11-04 22:53:06 +01:00
publicPath: 'http://localhost:1337/settings-manager/',
assetsPublicPath: '/settings-manager/',
2016-08-18 11:41:13 +02:00
},
2016-10-05 18:13:02 +02:00
// We use ExtractTextPlugin so we get a seperate SCSS file instead
2016-08-18 11:41:13 +02:00
// of the CSS being in the JS and injected as a style tag
2016-10-05 18:13:02 +02:00
cssLoaders: `style-loader!css-loader?localIdentName=${pluginId}[local]__[path][name]__[hash:base64:5]&modules&importLoaders=1&sourceMap!postcss-loader!sass-loader`,
2016-08-18 11:41:13 +02:00
// In production, we minify our CSS with cssnano
postcssPlugins: [
postcssFocus(),
cssnext({
browsers: ['last 2 versions', 'IE > 10'],
}),
postcssReporter({
clearMessages: true,
}),
],
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
children: true,
minChunks: 2,
async: true,
}),
// OccurrenceOrderPlugin is needed for long-term caching to work properly.
// See http://mxs.is/googmv
new webpack.optimize.OccurrenceOrderPlugin(true),
// Merge all duplicate modules
new webpack.optimize.DedupePlugin(),
// Minify and optimize the JavaScript
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false, // ...but do not show warnings in the console (there is a lot of them)
},
}),
// Extract the CSS into a seperate file
new ExtractTextPlugin('[name].[contenthash].css'),
],
});