Closed rogeriomq closed 6 years ago
@rogeriomq @ymzuiku I do get the same error as well.
I had the quite same issue. One look into the sourcecode shows that the plugin is trying to either
A: get the config from the package.json
B: read the confg from the file parcel-plugin-change-file.js
In my case (and yours) the file can't be read but you can still place the configuration in the package.json like this:
{
"name": "app",
"version": "1.0.0",
"private": true,
"dependencies": {
"parcel-bundler": "^1.10.3"
},
"devDependencies": {
"parcel-plugin-change-file": "1.3.0"
},
"parcel-plugin-change-file": {
"timeout": 30, // setTimeout replace Html file
"replaceName": "parcel-plugin-change-file", // default html replaceName
"html": ['hello'], // change string to html
"copy": ["src/assets"], // copy files in outDir
}
}
I had the quite same issue. One look into the sourcecode shows that the plugin is trying to either A: get the config from the package.json B: read the confg from the file
parcel-plugin-change-file.js
In my case (and yours) the file can't be read but you can still place the configuration in the package.json like this:
{ "name": "app", "version": "1.0.0", "private": true, "dependencies": { "parcel-bundler": "^1.10.3" }, "devDependencies": { "parcel-plugin-change-file": "1.3.0" }, "parcel-plugin-change-file": { "timeout": 30, // setTimeout replace Html file "replaceName": "parcel-plugin-change-file", // default html replaceName "html": ['hello'], // change string to html "copy": ["src/assets"], // copy files in outDir } }
Very Nice! Actually, I think there should be only the option via package.json should exist.
@SeriousM
The plan B you mentioned is quite easy to realize by adding the following code to the index.js
of this plugin (can be found in the node_modules
or just simply click the error log 😝 )
const configFilePath = path.resolve(process.cwd(), 'parcel-plugin-change-file.js');
// Assuming your parcel-plugin-change-file.js is in the root directory
Though you need to do this every time you install the plugin 😕
You can use patch-package to save changes you make to node modules and apply them after each install.
Aha great idea, the problem is perfectly solved then
When I run
parcel watch src / index.html --public-url ./ - out-dir dist /
I have the following output:⚠️ configFilePath is not defined at Object.<anonymous> (/home/man1gold/Projetos/www/cnt/www/modulos/administrativo/relatorio/node_modules/parcel-plugin-change-file/index.js:8:26) at Module._compile (/home/man1gold/.npm-global/lib/node_modules/parcel/node_modules/v8-compile-cache/v8-compile-cache.js:178:30) at Object.Module._extensions..js (module.js:664:10) at Module.load (module.js:566:32) at tryModuleLoad (module.js:506:12) at Function.Module._load (module.js:498:3) at Module.require (module.js:597:17) at require (/home/man1gold/.npm-global/lib/node_modules/parcel/node_modules/v8-compile-cache/v8-compile-cache.js:159:20) at localRequire (/home/man1gold/.npm-global/lib/node_modules/parcel/src/utils/localRequire.js:10:10) at <anonymous>
And the script in my index.html still remains commented out in dist / index.html: