-
Notifications
You must be signed in to change notification settings - Fork 158
/
webpack.demo.config.js
72 lines (65 loc) · 1.63 KB
/
webpack.demo.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
const webpack = require('webpack')
const path = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const PATH_ROOT = path.resolve(__dirname, './demo')
const PATH_SRC = path.resolve(PATH_ROOT, 'src/')
const PATH_OUT = path.resolve(PATH_ROOT, 'dist/')
module.exports = {
mode: 'production',
entry: [
path.resolve(PATH_SRC, 'index.js')
],
output: {
path: PATH_OUT,
filename: 'index.js'
},
module: {
rules: [
{
test: /\.js$/,
loaders: ['babel-loader'],
exclude: /node_modules/
},
{
test: /\.wasm$/,
type: 'javascript/auto',
loaders: ['arraybuffer-loader']
},
{
test: /\.scss$|\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{ loader: 'css-loader' },
{ loader: 'sass-loader' }
]
})
},
{
test: /\.jpg$|\.gif$|\.png$|\.svg$/,
use: ['url-loader']
},
{
test: /\.woff$|\.woff2$|\.eot$|\.tff$|\.ttf$/,
loader: 'file-loader?publicPath=../&name=./assets/fonts/[name].[ext]'
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: "'production'"
},
__DEVELOPMENT__: false
}),
new HtmlWebpackPlugin({
hash: true,
title: 'React-Mic',
filename: `${PATH_OUT}/index.html`,
template: `${PATH_SRC}/index.html`,
}),
new ExtractTextPlugin({ filename: 'bundle.css' })
]
}