“需要帮助了解”;提供您自己的网页配置;https://developer.wordpress.org/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\' ),
},
};
我在这里尝试从src文件夹向buid文件夹添加一个新的scipt,同时开发一个gutenberg blockI get错误:
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:
添加其他不同的css文件也是一样,我该怎么做?
SO网友:Grégoire Sailland
谢谢大家的帮助!我从几天开始就在上面!
我发现了我的问题:
https://webpack.js.org/concepts/entry-points/ 帮助我找到解决方案
显然地path.resolve( process.cwd(), \'src\', \'slider.js\' )
无法工作:替换为简单字符串路径修复了问题:
const defaultConfig = require( \'@wordpress/scripts/config/webpack.config\' );
module.exports = {
...defaultConfig,
entry: {
...defaultConfig.entry,
slider: \'./src/slider.js\',
},
};