-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
61 lines (57 loc) · 1.56 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
/**
* Sample webpack config.js (for webpack >2.4.0)
* Includes URL Loader
*/
const path = require('path');
const ExtractText = require('extract-text-webpack-plugin');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
var config = {
entry: ['./src/js/main.js', './src/scss/main.scss'],
output: {
filename: 'dist/js/[name].js'
},
module: {
rules: [
{ // STYLE LOADERS
test: /\.(css|sass|scss)$/,
use: ExtractText.extract({
use: ['css-loader', 'postcss-loader', 'sass-loader'],
})
},
{ // SCRIPT LOADERS
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['env']
}
},
{ // URL LOADER, IMAGE FILES
test: /\.(jpe?g|png|svg)/,
loader: 'url-loader?limit=10000&name=dist/img/[name].[ext]', //if < 10 kb, base64 encode img to css
},
{ // URL LOADER, FONT FILES
test: /\.(woff|woff2|eot|ttf)/,
loader: 'url-loader?limit=10000&name=dist/fonts/[name].[ext]', //font files to './dist/fonts/**.'
},
]
},
plugins: [
new ExtractText({
filename: 'dist/css/[name].css',
allChunks: true,
}),
new BrowserSyncPlugin({
host: 'localhost',
port: 3000,
// @NOTE: make sure this proxy matches the folder name of your wordpress installation
proxy: 'http://localhost/YOUR-THEME-NAME',
files: ['**/*.php'],
ghostMode: {
clicks: false,
forms: false
}
})
]
};
module.exports = config;