static-cms/packages/netlify-cms/webpack.config.js

57 lines
1.5 KiB
JavaScript
Raw Normal View History

const webpack = require('webpack');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const pkg = require('./package.json');
const { getConfig, plugins } = require('../../scripts/webpack');
const baseWebpackConfig = getConfig({ baseOnly: true });
2018-07-23 23:40:48 -04:00
const isProduction = process.env.NODE_ENV === 'production';
console.log(`${pkg.version}${isProduction ? '' : '-dev'}`);
const baseConfig = {
...baseWebpackConfig,
plugins: [
...Object.entries(plugins)
.filter(([key]) => key !== 'friendlyErrors')
.map(([, plugin]) => plugin()),
new webpack.DefinePlugin({
NETLIFY_CMS_VERSION: JSON.stringify(`${pkg.version}${isProduction ? '' : '-dev'}`),
}),
new FriendlyErrorsWebpackPlugin({
compilationSuccessInfo: {
messages: ['Netlify CMS is now running at http://localhost:8080'],
},
}),
2019-04-04 11:16:06 -07:00
new CopyWebpackPlugin([{ from: './shims/cms.css', to: './' }]),
],
devServer: {
contentBase: '../../dev-test',
watchContentBase: true,
2019-03-22 18:18:30 -04:00
publicPath: '/dist/',
quiet: true,
host: 'localhost',
port: 8080,
},
};
if (isProduction) {
module.exports = [
baseConfig,
/**
* Output the same script a second time, but named `cms.js`, and with a
* deprecation notice.
*/
{
...baseConfig,
2019-04-04 11:16:06 -07:00
entry: ['./shims/deprecate-old-dist.js', baseConfig.entry],
output: {
...baseConfig.output,
filename: 'cms.js',
},
},
];
} else {
module.exports = baseConfig;
}