I currently have a webpack project and I have bundled halfmoon css and js together. The CSS part is working but the Javascript part does not work for some reason.
I have required both and Webpack says it is compiling both:
And some of the code in webpack’s bundle matches the code of Halfmoon’s. My problem is is that webpack might not be executing the code at all. Then I added console.log("Webpack loaded!");
to the bundle, actually works:
webpack.config.js
const path = require("path");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
module.exports = {
entry: "./src/index.js",
mode: "development",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist")
},
module: {
rules: [
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
}
]
},
plugins: [new CleanWebpackPlugin()]
};
src/index.js
require("halfmoon/css/halfmoon.min.css"); // require halfmoon.css
require("halfmoon/js/halfmoon.js"); // require halfmoon.js
console.log("Webpack loaded!");
Code: https://glitch.com/edit/#!/cold-sly-maxilla
Project URL: https://cold-sly-maxilla.glitch.me/
Oh and by the way, halfmoon sets a “halfmoon” variable but it keeps saying Uncaught ReferenceError: halfmoon is not defined
which is weird.