From 815b190d28cc42e6f3d44d04e1f1ebaea9208cf6 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Sat, 30 Oct 2021 22:44:55 +0200 Subject: chore: convert html files to php Now I can use php to determine current env and load static CSS file if it is prod. --- config/webpack/webpack.dev.js | 91 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 config/webpack/webpack.dev.js (limited to 'config/webpack/webpack.dev.js') 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', +}; -- cgit v1.2.3