-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
106 lines (104 loc) · 2.94 KB
/
webpack.config.js
File metadata and controls
106 lines (104 loc) · 2.94 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const path = require('path');
const autoprefixer = require('autoprefixer');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = e => {
let env = e;
if (!env) env = { production: false };
const webpackConfigClient = {
mode: env.production ? 'production' : 'development',
entry: './src/index.jsx',
output: {
path: path.join(__dirname, './dist'),
filename: 'bundle.[chunkhash:8].js',
publicPath: '/',
},
resolve: {
modules: ['node_modules'],
extensions: ['.js', '.jsx', '.json'],
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: [/node_modules/, /test/],
loader: ['babel-loader'],
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 1,
modules: true,
localIdentName: '[name]__[local]___[hash:base64:5]',
sourceMap: true,
},
},
{
loader: require.resolve('postcss-loader'),
options: {
// Necessary for external CSS imports to work
// https://github.com/facebookincubator/create-react-app/issues/2677
ident: 'postcss',
plugins: () => [
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
],
flexbox: 'no-2009',
}),
],
sourceMap: true,
},
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
},
},
],
},
{
test: /\.(ttf|eot|svg|woff|woff2|png|jpg|jpeg)(\?.+)?$/,
loader: 'file-loader?name=[hash:12].[ext]',
},
{
test: /\.html$/,
loader: 'html-loader',
},
// ** STOP ** Are you adding a new loader?
// Make sure to add the new loader(s) before the "file" loader.
],
},
plugins: [
new CleanWebpackPlugin(),
new MiniCssExtractPlugin({
filename: 'styles/[name].[chunkhash:8].css',
}),
new HtmlWebpackPlugin({
template: 'src/index.html',
}),
],
devServer: {
contentBase: '/dist',
port: 8080,
historyApiFallback: true,
disableHostCheck: true,
},
externals: {},
target: 'web',
};
return webpackConfigClient;
};