admin管理员组文章数量:1304911
Need help understanding "Provide your own webpack config"
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
module.exports = {
...defaultConfig,
entry: {
...defaultConfig.entry,
//index: path.resolve( process.cwd(), 'src', 'index.js' ),
slider: path.resolve( process.cwd(), 'src', 'slider.js' ),
},
};
I am trying here to add a new scipt to the buid folder from src folder while developing a gutenberg block I get error:
ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `wp-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
Same for Adding other distinct css file how can I do it?
Need help understanding "Provide your own webpack config" https://developer.wordpress/block-editor/packages/packages-scripts/#provide-your-own-webpack-config
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
module.exports = {
...defaultConfig,
entry: {
...defaultConfig.entry,
//index: path.resolve( process.cwd(), 'src', 'index.js' ),
slider: path.resolve( process.cwd(), 'src', 'slider.js' ),
},
};
I am trying here to add a new scipt to the buid folder from src folder while developing a gutenberg block I get error:
ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `wp-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
Same for Adding other distinct css file how can I do it?
Share Improve this question edited Jan 28, 2021 at 11:03 kero 6,3201 gold badge25 silver badges34 bronze badges asked Jan 28, 2021 at 10:56 GSAGSA 414 bronze badges 7 | Show 2 more comments1 Answer
Reset to default 0Thank you all for your help! I was on it since days!
I found my problem:
https://webpack.js/concepts/entry-points/ helped me to find the solution
Apparently path.resolve( process.cwd(), 'src', 'slider.js' )
was not working:
replacing by simple string path fixed the problem:
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
module.exports = {
...defaultConfig,
entry: {
...defaultConfig.entry,
slider: './src/slider.js',
},
};
版权声明:本文标题:Gutenberg Block Development: Trying to add custom js script to npm start command by modifying webpack.config 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741797054a2397995.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
slider: ...
part, does it work? Does the full log (from the file) have more details on what is actually going wrong? – kero Commented Jan 28, 2021 at 11:05./src/slider.js
exists and has code in it that doesn't produce errors? – kero Commented Jan 28, 2021 at 11:09wp-scripts start
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: – GSA Commented Jan 28, 2021 at 11:16