-
Notifications
You must be signed in to change notification settings - Fork 16
Description
node版本:v18.20.2
pnpm版本:v9.12.2
问题:当我通过 amis init --editor=amis创建了一个文件夹取名为mydemo,然后我在mydemo中启动终端,使用pnpm i,依赖包下载完毕后,使用npm run dev进行启动,发生错误:Module not found: Error: Can't resolve 'html-loader' in '/Users/a111/Desktop/AMIS/myDemo',当我下载了html-loader'后出现了Module not found: Error: Can't resolve 'babel-loader' in '/Users/a111/Desktop/AMIS/myDemo',然后还有找不到:vue-loder,css-loder,vue-css-loder等等
webpack配置时原始配置没有动过
这是amis.config.js配置:
'use strict';
const path = require('path');
// 统一路径解析
function resolve(dir) {
return path.resolve(__dirname, dir);
}
// 包括生产和开发的环境配置信息
module.exports = {
settings: {
enableESLint: false, // 调试模式是否开启ESLint,默认开启ESLint检测代码格式
enableESLintFix: false, // 是否自动修正代码格式,默认不自动修正
enableStyleLint: false, // 是否开启StyleLint,默认开启ESLint检测代码格式
enableStyleLintFix: false // 是否需要StyleLint自动修正代码格式
},
webpack: {
resolve: {
// webpack的resolve配置
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue', '.umd.js', '.min.js', '.json'], // 用于配置webpack在尝试过程中用到的后缀列表
alias: {
'@': resolve('src'),
$function: resolve('src/function'),
$utils: resolve('src/utils'),
},
},
// createDeclaration: true, // 打包时是否创建ts声明文件
ignoreNodeModules: false, // 打包时是否忽略 node_modules
projectDir: ['src', 'editor'],
postCssLoaderOption: {
postcssOptions: {
plugins: [
require('postcss-pxtorem')({
rootValue: 16, // 1rem 等于 16px
propList: ['*'], // 所有属性都转换
}),
],
}
},
// template: resolve('./editor/index.html'), // dev本地调试时需要html模板
},
dev: {
entry: { // 本地编辑器中预览自定义组件
index: [
'./src/react-widget/index.js',
'./src/react-widget/plugin/info-card-plugin.jsx',
'./src/vue-widget/index.js',
'./src/vue-widget/plugin/info-card-plugin.jsx',
'./src/hello-jquery/hello-jquery.jsx',
'./src/hello-jquery/plugin/hello-jquery-plugin.jsx',
],
},
// 用于开启本地调试模式的相关配置信息
NODE_ENV: 'development',
port: 80,
autoOpenBrowser: true,
assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
assetsSubDirectory: '',
hostname: 'localhost',
cssSourceMap: false,
closeHotReload: true, // 是否关闭热更新
},
preview: {
entry: { // 预览自定义组件内容
index: './src/preview.js',
},
// 用于开启本地调试模式的相关配置信息
NODE_ENV: 'development',
port: 80,
autoOpenBrowser: true,
assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
assetsSubDirectory: '',
hostname: 'localhost',
proxyTable: {
'/apiTest': {
target: 'http://api-test.com.cn', // 不支持跨域的接口根地址
ws: true,
changeOrigin: true
}
},
cssSourceMap: true,
closeHotReload: false, // 是否关闭热更新
},
linkDebug: {
entry: { // 外链调试(amis-saas中预览自定义组件)
index: [
'./src/react-widget/index.js',
'./src/react-widget/plugin/info-card-plugin.jsx',
'./src/vue-widget/index.js',
'./src/vue-widget/plugin/info-card-plugin.jsx',
'./src/hello-jquery/hello-jquery.jsx',
'./src/hello-jquery/plugin/hello-jquery-plugin.jsx',
],
},
// 用于开启本地调试模式的相关配置信息
NODE_ENV: 'production',
port: 80,
autoOpenBrowser: false,
closeHtmlWebpackPlugin: true, // 关闭HtmlWebpackPlugin
assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
assetsSubDirectory: '',
hostname: 'localhost',
proxyTable: {
'/apiTest': {
target: 'http://api-test.com.cn', // 不支持跨域的接口根地址
ws: true,
changeOrigin: true
}
},
cssSourceMap: true,
closeHotReload: true, // 是否关闭热更新
},
build2lib: {
entry: {
// 自定义组件入口文件
reactInfoCard: './src/react-widget/index.js',
reactInfoCardPlugin: './src/react-widget/plugin/info-card-plugin.jsx',
infoCard: './src/vue-widget/index.js',
infoCardPlugin: './src/vue-widget/plugin/info-card-plugin.jsx',
helloJquery: './src/hello-jquery/hello-jquery.jsx',
helloJqueryPlugin: './src/hello-jquery/plugin/hello-jquery-plugin.jsx'
},
// 用于构建生产环境代码的相关配置信息
NODE_ENV: 'production', // development / production
libraryName: 'amisWidget', // 构建第三方功能包时最后导出的引用变量名
assetsRoot: resolve('./dist'), // 打包后的文件绝对路径(物理路径)
assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
assetsSubDirectory: '', // 资源引用二级路径
ignoreNodeModules: true, // 打包时是否忽略 node_modules
allowList: [], // ignoreNodeModules为true时生效
productionSourceMap: false,
productionGzip: false,
productionGzipExtensions: ['js', 'css', 'json'],
bundleAnalyzerReport: false,
}
};