-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwebpack.config.dll.js
157 lines (152 loc) · 4.33 KB
/
webpack.config.dll.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// ------------------------------------------
// OPTIMIZING WEBPACK FOR FASTER BUILDS
// ------------------------------------------
// See: https://brunolm.wordpress.com/2017/03/24/webpack-dllplugin-and-dllreferenceplugin/
// See: http://engineering.invisionapp.com/post/optimizing-webpack/
// See: https://medium.com/@soederpop/webpack-plugins-been-we-been-keepin-on-the-dll-cdfdd6cb8cd7
// See: https://robertknight.github.io/posts/webpack-dll-plugins/
// See: http://odetocode.com/blogs/scott/archive/2016/12/01/building-vendor-and-feature-bundles-with-webpack.aspx
// See: https://engineering.bitnami.com/articles/optimizing-your-webpack-builds.html
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const node_modules = path.resolve(process.cwd(), 'node_modules');
const src = path.resolve(process.cwd(), 'src');
const dll = path.resolve(process.cwd(), 'dist');
module.exports = {
name: 'vendor',
context: process.cwd(),
devtool: '#source-map',
target: 'web', // Make web variables accessible to webpack, e.g. window
resolve: {
modules: [
src,
'node_modules',
],
},
entry: {
vendor: [
'./src/vendor.js'
],
},
output: {
path: dll,
filename: '[name].dll.js',
// The name of the global variable which the library's
// require() function will be assigned to
library: '[name]_[hash]'
},
plugins: [
new webpack.DllPlugin({
// The path to the manifest file which maps between
// modules included in a bundle and the internal IDs
// within that bundle
path: path.join(dll, '[name].dll.manifest.json'),
// The name of the global variable which the library's
// require function has been assigned to. This must match the
// output.library option above
name: '[name]_[hash]',
}),
new ExtractTextPlugin({
filename: '[name].styles.css',
allChunks: true,
disable: false,
ignoreOrder: false,
}),
],
module: {
rules: [
{
test: /\.css$/,
include: [
src,
],
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
url: true,
sourceMap: true,
importLoaders: 1,
modules: false,
minimize: false,
}
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
}
},
{
loader: 'resolve-url-loader'
},
]
})
},
{
test: /\.(scss|sass)$/,
include: [
src,
],
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
url: true,
sourceMap: true,
importLoaders: 2,
modules: false,
minimize: false
}
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
}
},
{
loader: 'resolve-url-loader'
},
{
loader: 'sass-loader',
options: {
outputStyle: 'expanded',
sourceMap: true,
sourceMapContents: false,
}
},
]
})
},
{
test: /\.(jpg|jpeg|gif|png)$/,
loader: 'url-loader?name=[name].[ext]&limit=8192&mimetype=image/[ext]'
},
{
test: /\.svg$/,
loader: 'url-loader?name=[name].[ext]&limit=10240&mimetype=image/svg+xml'
},
{
test: /\.woff[2]?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: ['url-loader?name=[name].[ext]&limit=10240&mimetype=application/font-[ext]']
},
{
test: /\.(ttf|eot)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: ['file-loader?name=[name].[ext]&limit=10240&mimetype=application/octet-stream']
},
{
test: /\.otf(\?.*)?$/,
loader: 'file-loader?name=[name].[ext]&limit=10240&mimetype=font/opentype'
},
],
},
performance: {
hints: false
},
};