You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Npm run start: All the source files which are compiled via copy-webpack-plugin the options.plugins are not rendered/copied to build directory whenever there is a HOT RELOAD. In the first run, the result is as expected.
Example: Manifest.json.
FYT: My webpack.config.js
var webpack = require("webpack"),
path = require("path"),
fileSystem = require("fs"),
env = require("./utils/env"),
CleanWebpackPlugin = require("clean-webpack-plugin").CleanWebpackPlugin,
CopyWebpackPlugin = require("copy-webpack-plugin"),
HtmlWebpackPlugin = require("html-webpack-plugin"),
WriteFilePlugin = require("write-file-webpack-plugin");
// load the secrets
var alias = {};
var secretsPath = path.join(__dirname, ("secrets." + env.NODE_ENV + ".js"));
var fileExtensions = ["jpg", "jpeg", "png", "gif", "eot", "otf", "svg", "ttf", "woff", "woff2"];
if (fileSystem.existsSync(secretsPath)) {
alias["secrets"] = secretsPath;
}
var options = {
mode: process.env.NODE_ENV || "development",
entry: {
popup: path.join(__dirname, "src", "js", "popup.js"),
options: path.join(__dirname, "src", "js", "options.js"),
background: path.join(__dirname, "src", "js", "background", "index.js"),
contentScript: path.join(__dirname, "src", "js", "content-scripts", "index.js")
},
chromeExtensionBoilerplate: {
notHotReload: ["contentScript"]
},
output: {
path: path.join(__dirname, "build"),
filename: "[name].bundle.js"
},
module: {
rules: [
{
test: /\.css$/,
loader: "style-loader!css-loader",
exclude: /node_modules/
},
{
test: new RegExp('\.(' + fileExtensions.join('|') + ')$'),
loader: "file-loader?name=[name].[ext]",
exclude: /node_modules/
},
{
test: /\.html$/,
loader: "html-loader",
exclude: /node_modules/
},
{
test: /\.(js|jsx)$/,
loader: "babel-loader",
exclude: /node_modules/
}
]
},
resolve: {
alias: alias,
extensions: fileExtensions.map(extension => ("." + extension)).concat([".jsx", ".js", ".css"]),
modules: [path.resolve(__dirname, 'src'), 'node_modules'],
},
plugins: [
// clean the build folder
new CleanWebpackPlugin(),
// expose and write the allowed env vars on the compiled bundle
new webpack.EnvironmentPlugin(["NODE_ENV"]),
new CopyWebpackPlugin([{
from: "src/manifest.json",
transform: function (content, path) {
// generates the manifest file using the package.json informations
return Buffer.from(JSON.stringify({
description: process.env.npm_package_description,
version: process.env.npm_package_version,
...JSON.parse(content.toString())
}))
}
}]),
new CopyWebpackPlugin([{
from: 'src/css/inject.css',
to: 'inject.css',
toType: 'file'
}]),
new CopyWebpackPlugin([{
from: 'src/js/content-scripts/captureXHRResponse.js',
to: 'captureXHRResponse.js',
toType: 'file'
}]),
new CopyWebpackPlugin([{
from: 'src/img/download.png',
to: 'download.png',
toType: 'file'
}]),
new HtmlWebpackPlugin({
template: path.join(__dirname, "src", "popup.html"),
filename: "popup.html",
chunks: ["popup"]
}),
new HtmlWebpackPlugin({
template: path.join(__dirname, "src", "options.html"),
filename: "options.html",
chunks: ["options"]
}),
new WriteFilePlugin()
]
};
/*if (env.NODE_ENV === "development") {
options.devtool = "cheap-module-eval-source-map";
}*/
options.devtool = "cheap-module-eval-source-map";
module.exports = options;
Node version: 12.x
The text was updated successfully, but these errors were encountered:
Hello,
Context
Npm run build
: OK.Npm run start
: All the source files which are compiled via copy-webpack-plugin theoptions.plugins
are not rendered/copied tobuild
directory whenever there is a HOT RELOAD. In the first run, the result is as expected.Example: Manifest.json.
FYT: My
webpack.config.js
Node version: 12.x
The text was updated successfully, but these errors were encountered: