-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
81 lines (77 loc) · 2.23 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
const path = require('path');
const webpack = require('webpack');
/*
* Webpack Plugins
*/
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ProductionPlugins = [
// production webpack plugins go here
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production")
}
})
]
const debug = (process.env.NODE_ENV !== 'production');
const rootAssetPath = path.join(__dirname, 'assets');
module.exports = {
// configuration
context: __dirname,
entry: {
main_js: './assets/js/main',
main_css: [
path.join(__dirname, 'node_modules', '@fortawesome', 'fontawesome-free', 'css', 'all.css'),
path.join(__dirname, 'node_modules', 'bootstrap', 'dist', 'css', 'bootstrap.css'),
path.join(__dirname, 'assets', 'css', 'style.css'),
],
},
mode: debug,
output: {
chunkFilename: "[id].js",
filename: "[name].bundle.js",
path: path.join(__dirname, "radio_chaser", "static", "build"),
publicPath: "/static/build/"
},
resolve: {
extensions: [".js", ".jsx", ".css"]
},
devtool: debug ? "eval-source-map" : false,
plugins: [
new MiniCssExtractPlugin({ filename: "[name].bundle.css" }),
new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery" })
].concat(debug ? [] : ProductionPlugins),
module: {
rules: [
{
test: /\.less$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
},
},
'css-loader!less-loader',
],
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
},
},
'css-loader',
],
},
{ test: /\.html$/, loader: 'raw-loader' },
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader', options: { limit: 10000, mimetype: 'application/font-woff' } },
{
test: /\.(ttf|eot|svg|png|jpe?g|gif|ico)(\?.*)?$/i,
loader: 'file-loader',
options: { context: rootAssetPath, name: '[path][name].[ext]' }
},
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader', options: { presets: ["@babel/preset-env"], cacheDirectory: true } },
],
}
};