-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
90 lines (86 loc) · 2.71 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
const path = require('path')
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const ManifestRevisionPlugin = require('manifest-revision-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const webpack = require('webpack')
const rootAssetPath = './app/static'
const devMode = process.env.NODE_ENV !== 'production'
module.exports = (env, options) => {
return {
entry: {
app: [
path.resolve(__dirname, './app/templates/app.js')
],
vender_css: [
path.resolve(__dirname, './node_modules/bootstrap/dist/css/bootstrap.min.css')
]
},
output: {
path: path.resolve(__dirname, './build/public'),
publicPath: 'http://localhost:2992/assets/',
filename: '[name].[chunkhash].js',
chunkFilename: '[id].[chunkhash].js'
},
resolve: {
extensions: ['.js', '.css']
},
devServer: {
headers: { "Access-Control-Allow-Origin": "*" }
},
module: {
rules: [
{
test: /\.(py|pyc|html)$/,
loader: 'ignore-loader'
},
{
test: /\.css$/i,
use: [
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader'
]
},
{
test: /\.js$/i, use: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "file-loader"
},
{
test: /\.(jpe?g|png|gif|otf)(\?v=[0-9]\.[0-9]\.[0-9])?$/i,
use: [
{
loader: 'file-loader',
options: {
name (file) {
if (env === 'development') {
return '[path][name].[ext]'
}
return '[hash].[ext]'
},
outputPath: rootAssetPath + '/images'
}
}
]
}
]
},
plugins: [
new UglifyJsPlugin(),
new MiniCssExtractPlugin({
filename: "[name].[hash].css",
chunkFilename: "[id].[hash].css"
}),
new ManifestRevisionPlugin(path.join('build', 'manifest.json'), {
rootAssetPath: rootAssetPath,
ignorePaths: ['/images']
})
]
}
}