-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
107 lines (103 loc) · 2.32 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
101
102
103
104
105
106
107
const webpack = require( 'webpack' );
const FriendlyErrors = require( 'friendly-errors-webpack-plugin' );
const path = require( 'path' );
const src = path.resolve( __dirname, 'src' );
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
const requireDesired = require( './build/modules/require-desired.js' );
const merge = require( 'webpack-merge' );
const localConfig = merge( requireDesired( `${__dirname}/build/config` ), requireDesired( `${__dirname}/build/config.local` ) );
const RuntimePath = require( 'webpack-runtime-public-path-plugin' );
if ( 'development' === localConfig.mode ) {
process.env.NODE_ENV = 'development';
}
const webpackConfig = merge( {
mode: process.env.NODE_ENV || 'production',
context: src,
output: {
path: path.resolve( __dirname, 'boldgrid-theme-framework' ),
publicPath: '/wp-content/themes/prime/inc/boldgrid-theme-framework/'
},
devServer: {
publicPath: '/wp-content/themes/prime/inc/boldgrid-theme-framework/',
contentBase: '/wp-content/themes/prime/inc/boldgrid-theme-framework/',
historyApiFallback: true,
quiet: true,
port: 4009,
overlay: {
errors: true,
warnings: true
}
},
module: {
rules: [
{
test: /\.ejs$/,
loader: 'ejs-loader'
},
{
test: /\.html$/,
use: [
{
loader: 'html-loader',
options: {
minimize: true
}
}
]
},
{
test: /\.svg$/,
loader: 'svg-inline-loader'
},
{
test: /\.s?[ac]ss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
// 'postcss-loader',
{
loader: 'sass-loader',
options: {
includePaths: [
path.resolve( __dirname, 'node_modules' )
]
}
}
]
},
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: [ '@babel/preset-env' ]
}
}
},
{
test: /\.js$/,
enforce: 'pre',
exclude: /node_modules/,
loader: 'eslint-loader',
options: {
emitWarning: true
}
}
]
},
plugins: [
new RuntimePath( {
runtimePublicPath: 'BGTFW.assets.path'
} ),
new MiniCssExtractPlugin( {
filename: './assets/css/[name]-bundle.min.css'
} ),
new webpack.ProvidePlugin( {
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
} ),
new FriendlyErrors()
]
}, localConfig );
module.exports = webpackConfig;