Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
74 lines (72 loc) · 1.86 KB
/
Copy pathwebpack.config.js
File metadata and controls
74 lines (72 loc) · 1.86 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
var webpack = require('webpack');
var ManifestPlugin = require('webpack-manifest-plugin');
var path = require('path');
const publicPath = '/wp-content/themes/the-fastest';
const pathToTheme = path.resolve(__dirname, './'+publicPath);
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
entry: {
index: pathToTheme+'/src/js/index.js',
blog: pathToTheme+'/src/js/blog.js',
above: pathToTheme+'/src/js/above.js',
landing: pathToTheme+'/src/js/landing.js'
},
output: {
path: pathToTheme+'/public/',
publicPath: publicPath+'/public/'
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/
},
{
test: /\.(css|scss)$/, use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: "css-loader" // translates CSS into CommonJS
},
{
loader: "sass-loader" // compiles Sass to CSS
}]
}, //css only files
{
test: /\.(png|svg|jpg|gif)$/, use: {
loader: 'file-loader',
options: { name: '[name].[ext]' }
}
}, //for images
{
test: require.resolve('jquery'),
use: [{
loader: 'expose-loader',
options: 'jQuery'
},{
loader: 'expose-loader',
options: '$'
}]
},
{ test: /\.woff($|\?)|\.woff2($|\?)|\.ttf($|\?)|\.eot($|\?)|\.svg($|\?)/, use: ['file-loader'] } //for fonts
]
},
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
test: /node_modules/,
chunks: 'initial',
name: 'vendor',
enforce: true
},
}
}
},
plugins: [
new ManifestPlugin({
publicPath: ''
})
]
};