-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.babel.js
91 lines (88 loc) · 2.12 KB
/
webpack.config.babel.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
import path from 'path'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import ManifestPlugin from 'webpack-manifest-plugin'
import webpack from 'webpack'
export default function ({
prod = false
} = {}) {
const outFolder = prod ? path.resolve(__dirname, './build/public/assets') : path.resolve(__dirname, './src/public/assets')
const plugins = [
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.LoaderOptionsPlugin({
options: {
babel: {
presets: [
['es2015', {modules: false}]
],
plugins: ['transform-runtime']
}
}
})
]
return {
entry: {
main: ['./src/frontend/main.js', './src/frontend/style/main.scss'],
polyfill: ['core-js/es6/array', 'core-js/es6/object', 'core-js/es6/promise']
},
output: {
filename: prod ? '[name].[chunkhash].bundle.js' : '[name].js',
path: outFolder,
publicPath: '/assets/',
chunkFilename: prod ? '[name].[id].[chunkhash].js' : '[name].[id].js'
},
module: {
rules: [
{
// Vue files
test: /\.vue$/,
loader: 'vue-loader'
},
{
// JS
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
// Sass
test: /\.scss$/,
// Disable sass minification so css-loader handles it
loader: prod ? ExtractTextPlugin.extract(['css-loader', 'sass-loader?outputStyle=nested']) : ['style-loader', 'css-loader', 'sass-loader']
},
{
// JaaaaSON
test: /\.json$/,
loader: 'json-loader'
},
{
// Images and other shenaniganiganidingdongs
test: /\.(png|jpe?g|gif|svg|woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
query: {
limit: 10000,
name: prod ? '[name].[hash:7].[ext]' : '[name].[ext]'
}
}
]
},
plugins: plugins.concat(prod ?
[
new ManifestPlugin({
basePath: '/assets/',
fileName: '../manifest.json'
}),
new ExtractTextPlugin('[name].[contenthash].css'),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
] : []
)
}
}