-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.common.js
More file actions
74 lines (64 loc) · 1.77 KB
/
Copy pathwebpack.common.js
File metadata and controls
74 lines (64 loc) · 1.77 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// https://gist.github.com/vincentbollaert/e90def9b351d8d97c90ef7cfd887685e
const webpack = require('webpack')
const HtmlWebPackPlugin = require('html-webpack-plugin')
const path = require('path')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const entryPath = './src/index.jsx'
const outputPath = './public'
const PUBLIC_PATH = '/'
const config = {
entry: {
main: path.resolve(__dirname, entryPath),
},
output: {
path: path.resolve(__dirname, outputPath),
publicPath: PUBLIC_PATH,
filename: '[name].bundle.[hash].js',
chunkFilename: '[name].bundle.[hash].js',
},
externals: {
cheerio: 'window',
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': true,
},
resolve: {
extensions: ['.js', '.jsx'],
},
module: {
rules: [
{ test: /\.(js|jsx)$/, use: 'babel-loader' },
{ test: /\.html$/, use: 'html-loader' },
{ test: /\.md$/, use: ['html-loader', 'highlight-loader', 'markdown-loader'] },
{ test: /\.svg$/, use: 'raw-loader' },
{
test: /\.(woff|ttf|eot)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: 'file-loader',
},
{
test: /\.(ico|jpe?g|png)$/i,
loader: 'file-loader',
options: {
name: 'assets/img/[name].[ext]',
},
},
],
},
plugins: [
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/),
new MiniCssExtractPlugin({
fileName: 'style.css',
}),
new HtmlWebPackPlugin({
template: './src/index.html',
filename: 'index.html',
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('development'),
},
}),
],
}
module.exports = config