This repository has been archived by the owner on May 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.common.js
98 lines (83 loc) · 1.76 KB
/
webpack.common.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
const CopyWebpackPlugin = require('copy-webpack-plugin')
const ExtractTextWebpackPlugin = require('extract-text-webpack-plugin')
const nodeExternals = require('webpack-node-externals')
const app = {
entry: {
app: './app/index.jsx',
vendors: './app/vendors.js'
},
target: 'web',
output: {
path: __dirname + '/public/js',
filename: '[name].js',
},
resolve: {
extensions: [".js", ".jsx", ".json"],
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules|vendors)/,
use: ['babel-loader'],
},
],
},
}
const assets = {
entry: {
app: [
'./node_modules/bootstrap/dist/css/bootstrap.min.css',
'./node_modules/highlight.js/styles/github-gist.css',
'./app/css/index.css',
],
},
output: {
path: __dirname + '/build',
filename: '[name].css',
},
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextWebpackPlugin.extract({
fallback: 'style-loader',
use: 'css-loader',
}),
},
{
test: /\.(gif|jpg|png|woff2)$/,
use: [{
loader: 'url-loader',
options: {
limit: 1024,
},
}],
},
],
},
plugins: [
new CopyWebpackPlugin(
[
{
from: __dirname + '/node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff2',
to: __dirname + '/public/fonts',
},
]
),
new ExtractTextWebpackPlugin('app.css'),
],
}
const server = {
entry: './src/index.js',
target: 'node',
output: {
path: __dirname + '/build',
filename: 'index.js',
},
resolve: {
extensions: [".js", ".json"],
},
externals: [nodeExternals()],
}
module.exports = [app, assets, server]