register extensions for development
This commit is contained in:
@ -1,10 +1,26 @@
|
||||
const path = require('path');
|
||||
const { getConfig, rules } = require('../../scripts/webpack.js');
|
||||
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
|
||||
const { getConfig, rules, plugins } = require('../../scripts/webpack.js');
|
||||
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
|
||||
const entry = () => {
|
||||
const defaultEntry = ['./index.js'];
|
||||
|
||||
if (isProduction) {
|
||||
return defaultEntry;
|
||||
}
|
||||
|
||||
return [
|
||||
...defaultEntry,
|
||||
'../scripts/load-extensions.js',
|
||||
];
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
...getConfig(),
|
||||
context: path.join(__dirname, 'src'),
|
||||
entry: './index.js',
|
||||
entry: entry(),
|
||||
module: {
|
||||
rules: [
|
||||
...Object.entries(rules)
|
||||
@ -26,5 +42,22 @@ module.exports = {
|
||||
use: ['to-string-loader', 'css-loader'],
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
...Object.entries(plugins)
|
||||
.filter(([ key ]) => key !== 'friendlyErrors')
|
||||
.map(([ _, plugin ]) => plugin()),
|
||||
new FriendlyErrorsWebpackPlugin({
|
||||
compilationSuccessInfo: {
|
||||
messages: ['Netlify CMS is now running at http://localhost:8080'],
|
||||
},
|
||||
}),
|
||||
],
|
||||
devServer: {
|
||||
contentBase: './example',
|
||||
watchContentBase: true,
|
||||
quiet: true,
|
||||
host: 'localhost',
|
||||
port: 8080,
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user