This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
100 lines (94 loc) · 1.9 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
'use strict'
const path = require('path')
const BrowserSyncPlugin = require('browser-sync-webpack-plugin')
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader')
// Entry points
// (each entry point will result in a bundled JS file)
const entryPoint = {
frontend: './src/frontend/index.js'
// add as many you need
}
// Path to public/build folder
let buildPath = path.resolve(__dirname, 'public')
var config = {
entry: entryPoint,
output: {
filename: '[name].js',
path: buildPath
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
},
{
enforce: 'pre',
test: /\.(js|vue)$/,
exclude: /node_modules/,
loader: 'eslint-loader',
options: {
formatter: require('eslint-friendly-formatter')
}
},
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
extractCSS: true
}
},
{
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader'
]
},
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
}
]
},
plugins: [
new BrowserSyncPlugin({
// Host and port
host: 'localhost',
port: 3000,
// A target to proxy all BrowserSync requests to.
// This can be a local web server, Vagrant or a docker container.
// This is your local/VM WordPress development site.
proxy: 'localhost'
}),
new VueLoaderPlugin()
],
optimization: {
minimizer: [
// Code minimization (production mode only)
new UglifyJSPlugin({
uglifyOptions: {
compress: {
drop_console: true
}
},
sourceMap: true
})
]
}
}
module.exports = (env, argv) => {
// Production mode?
if (argv.mode === 'production') {
config.devtool = false
config.output.filename = '[name].min.js'
}
return config
}