forked from decaporg/decap-cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.js
59 lines (51 loc) · 1.58 KB
/
webpack.prod.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* global module, __dirname, require */
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = merge.smart(require('./webpack.base.js'), {
entry: {
cms: './index',
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
library: 'netlify-cms',
libraryTarget: 'umd',
umdNamedDefine: true,
},
context: path.join(__dirname, 'src'),
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
new webpack.DefinePlugin({
NETLIFY_CMS_VERSION: JSON.stringify(require("./package.json").version),
}),
// Combine/hoist module scopes when possible.
new webpack.optimize.ModuleConcatenationPlugin(),
// Minify and optimize the JavaScript
new UglifyJsPlugin({
sourceMap: true,
}),
// Extract CSS
new ExtractTextPlugin({
filename: '[name].css',
allChunks: true
}),
// During beta phase, generate source maps for better errors
new webpack.SourceMapDevToolPlugin({
// asset matching
test: /\.js?$/,
// file and reference
filename: '[file].map',
// don't include source file content, since we link to the actual file
noSources: true,
// sourcemap is in 'dist', webpack context is in 'src'
moduleFilenameTemplate: info => path.posix.normalize(`../src/${info.resourcePath}`),
}),
],
});