D
D
Dubolom Unicellular2020-08-03 15:14:05
JavaScript
Dubolom Unicellular, 2020-08-03 15:14:05

How to make two output in webpack?

How to make two exits in webpack config?
I need the js to go to the dist folder and the html (compiled pug) to go to the public folder.

Here is an example config with pug:

const fs = require("fs");
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");

const PAGES_DIR = path.join(__dirname, "/src/pug/pages")
const PAGES = fs.readdirSync(PAGES_DIR)
  .filter(fileName => fileName.endsWith(".pug"));

module.exports = {
  mode: "development",
  entry: path.join(__dirname, "/src/js/app.js"),
  output: {
    path: path.join(__dirname, "/dist"),
    filename: "bundle.js"
  },
  devServer: {
    port: 3000
  },
  module: {
    rules: [
      {
        test: /\.pug$/,
        use: "pug-loader"
      }
    ]
  },
  plugins: [
    ...PAGES.map(page => new HtmlWebpackPlugin({
      template: `${PAGES_DIR}/${page}`,
      filename: `./${page.replace(/\.pug$/, ".html")}`
    }))
  ]
};


How to do it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Ksenia P., 2020-08-13
@kplatova

If you want to have 2 folders dist and public at the top level, then you need to specify '/' in the output and specify the full path in the generated css, js and html:


output: {
path: path.join(__dirname, "/"),
filename: "/dist/bundle.js"
},
filename: `/public/${page.replace(/\.pug$/, ".html ")}`

2 output cannot be done.

D
Dmitry Entelis, 2015-02-21
@DmitriyEntelis

Perhaps stackoverflow.com/questions/8751221/php-timezone-d...
will help you... But in general, it is better to ask questions about little-known tsms on their forums

A
Andrey Boychenko, 2015-02-21
@Ka4_Piton

I suspect that you need to set the correct time zone in php.ini either using date_default_timezone_set('Europe/London');
But this is not accurate, but I think it will help) In any case, write back if you solved the problem and in what way. The CMS itself is not interesting to me, but the issue related to the occurrence of php errors is quite interesting. I am still in the learning process.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question