-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
113 lines (109 loc) · 2.56 KB
/
webpack.config.js
File metadata and controls
113 lines (109 loc) · 2.56 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
const path = require("path")
const webpack = require("webpack") // eslint-disable-line no-unused-vars
const BundleTracker = require("webpack-bundle-tracker")
const config = {
context: __dirname,
entry: {
bootstrap: "./la_metro_translations/static/js/bootstrap.js",
react_block: "./la_metro_translations/static/js/react_block.js",
},
output: {
path: path.resolve(__dirname, "assets/bundles/"),
filename: "[name]-[hash].js",
chunkFilename: "[name]-[hash].js",
},
plugins: [
new BundleTracker({
path: __dirname,
filename: "webpack-stats.json",
}),
],
devServer: {
watchFiles: ["la_metro_translations/static/**/*.js"],
host: "0.0.0.0",
port: 3000,
compress: false,
allowedHosts: ["localhost"],
},
watchOptions: {
poll: 1000,
},
resolve: {
extensions: [".js", ".jsx", ".geojson", ".scss", ".css"],
},
ignoreWarnings: [
{
module: /sass-loader/, // A RegExp
},
/warning from compiler/,
() => true,
],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-react"],
},
},
{
test: /\.geojson$/,
type: "json",
},
{
test: /\.css$/i,
use: [
// Creates `style` nodes from JS strings
"style-loader",
// Translates CSS into CommonJS
"css-loader",
],
},
{
test: /\.(scss)$/,
use: [
{
loader: "style-loader",
},
{
loader: "css-loader",
},
{
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: () => [require("autoprefixer")],
},
},
},
{
loader: "sass-loader",
},
],
},
{
test: /\.(jpg|png|mp4)$/,
use: {
loader: "url-loader",
},
},
],
},
}
module.exports = (env, argv) => {
/*
* /app/webpack-stats.json is the roadmap for the assorted chunks of JS
* produced by Webpack. During local development, the Webpack server
* serves our bundles. In production, Django should look in
* /app/static/bundles for bundles.
*/
if (argv.mode === "development") {
config.output.publicPath = "http://localhost:3000/static/bundles/"
}
if (argv.mode === "production") {
config.output.publicPath = "/static/bundles/"
}
return config
}