forked from michael-iglesias/material-ui-jsonschema-form
-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.js
executable file
·100 lines (97 loc) · 2.44 KB
/
webpack.config.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
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
/* eslint-disable */
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const babelExclude = /node_modules/;
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require("extract-text-webpack-plugin")
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const extractScss = new ExtractTextPlugin({ filename: "style.css", allChunks: true })
const extractCss = new ExtractTextPlugin({ filename: "main.css", allChunks: true })
const alias = {}
var config = {
entry: [
'react-hot-loader/patch',
'webpack-hot-middleware/client',
path.join(__dirname, 'demo/index.jsx')
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'demo.js',
publicPath: '/',
},
mode: process.env.NODE_ENV,
devtool: 'source-map',
module: {
rules: [{
oneOf: [{
test: /\.jsx?$/,
use: ['babel-loader'],
exclude: babelExclude,
},
{
test: /\.scss$/,
use: extractScss.extract({
use: [{
loader: 'css-loader',
options: {
localIdentName: '[path]__[name]__[local]__[hash:base64:5]',
modules: true,
camelCase: true,
}
}, {
loader: 'sass-loader',
}]
}),
},
{
test: /\.css$/,
use: extractCss.extract({
use: [{
loader: 'css-loader',
}]
}),
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
loaders: [{
loader: 'url-loader',
options: {
limit: 50000,
},
}, {
loader: 'image-webpack-loader',
}]
},
{
exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/, /.s?css$/],
loader: 'file-loader',
options: {
name: 'static/media/[name].[hash:8].[ext]',
},
},
]
}]
},
resolve: {
extensions: ['.js', '.jsx'],
alias,
modules: ['node_modules']
},
plugins: [
extractCss,
extractScss,
new HtmlWebpackPlugin({
template: 'demo/index.html',
}),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
],
target: 'web',
devServer: {
contentBase: path.join(__dirname, 'demo'),
compress: true,
port: 8080
}
}
module.exports = config