aboutsummaryrefslogtreecommitdiffstats
path: root/config/webpack/webpack.dev.js
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2021-10-30 22:44:55 +0200
committerArmand Philippot <git@armandphilippot.com>2021-10-30 23:09:33 +0200
commit815b190d28cc42e6f3d44d04e1f1ebaea9208cf6 (patch)
tree0d3f0133a39a4a796e698d360dc32f54fb41d8ad /config/webpack/webpack.dev.js
parent3a3baddad1c801d77dc398d2c6980f3c14f4a47c (diff)
chore: convert html files to php
Now I can use php to determine current env and load static CSS file if it is prod.
Diffstat (limited to 'config/webpack/webpack.dev.js')
-rw-r--r--config/webpack/webpack.dev.js91
1 files changed, 91 insertions, 0 deletions
diff --git a/config/webpack/webpack.dev.js b/config/webpack/webpack.dev.js
new file mode 100644
index 0000000..4ac420c
--- /dev/null
+++ b/config/webpack/webpack.dev.js
@@ -0,0 +1,91 @@
+const dartSass = require('sass');
+const paths = require('./paths');
+require('dotenv').config();
+
+const protocol = process.env.WEBPACK_PROTOCOL;
+const host = process.env.WEBPACK_HOST;
+const port = process.env.WEBPACK_PORT;
+const siteURL = `${protocol}://${host}/`;
+const isHttps = protocol === 'https';
+const isHMREnabled = process.env.WEBPACK_HOT_RELOAD === 'true';
+const isOpenBoolean = process.env.WEBPACK_OPEN === 'true' || process.env.WEBPACK_OPEN === 'false';
+
+module.exports = {
+ mode: 'development',
+ module: {
+ rules: [
+ {
+ test: /\.(sa|sc|c)ss$/i,
+ use: [
+ 'style-loader',
+ {
+ loader: 'css-loader',
+ options: {
+ importLoaders: 2,
+ sourceMap: true,
+ },
+ },
+ {
+ loader: 'postcss-loader',
+ options: {
+ postcssOptions: {
+ plugins: ['autoprefixer'],
+ },
+ sourceMap: true,
+ },
+ },
+ {
+ loader: 'sass-loader',
+ options: {
+ implementation: dartSass,
+ sassOptions: {
+ indentWidth: 2,
+ outputStyle: 'expanded',
+ includePaths: paths.sassPaths,
+ },
+ sourceMap: true,
+ },
+ },
+ ],
+ },
+ ],
+ },
+ devServer: {
+ client: {
+ overlay: {
+ warnings: true,
+ errors: true,
+ },
+ },
+ devMiddleware: {
+ writeToDisk: true,
+ },
+ host,
+ port,
+ hot: isHMREnabled,
+ https: !isHttps
+ ? false
+ : {
+ key: process.env.WEBPACK_HTTPS_KEY,
+ cert: process.env.WEBPACK_HTTPS_CERT,
+ },
+ liveReload: true,
+ open: isOpenBoolean
+ ? process.env.WEBPACK_OPEN
+ : {
+ app: {
+ name: process.env.WEBPACK_OPEN,
+ },
+ },
+ proxy: {
+ '/': {
+ target: siteURL,
+ changeOrigin: true,
+ secure: false,
+ },
+ },
+ static: false,
+ watchFiles: paths.files,
+ },
+ devtool: 'inline-source-map',
+};