老师帮忙看下运行报错
问题描述:webpack.config.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
//获取绝对路径
const resolve = dir => path.resolve(__dirname,dir);
module.exports = {
//production
mode:'development',
entry: {
index:'./src/pages/index/index.js' ,
},
output: {
path: resolve('dist'),
filename: 'js/[name].js'
},
//source-map 调试用的,出错时,直接定位到源码,而不是转换后的代码
devtool:'cheap-module-eval-source-map',
resolve:{
// 自动补全(可以省略)的扩展名
// import 'index <.js>';
extensions:['js'],
//路径别名
alias:{
api:resolve('src/api'),
fonts:resolve('src/assets/fonts'),
images:resolve('src/assets/images'),
styles:resolve('src/assets/styles'),
components:resolve('src/components'),
pages:resolve('src/pages')
}
},
module:{
rules:[
{
test:/\.css$/,
use:['style-loader','css-loader']
},
{
test:/\.art$/,
loader:'art-template-loader'
},
{
test:/\.(png|jpe?g|gif|svg)$/,
loader:'url-loader',
options:{
limit:10000,
name:'images/[name].[ext]',
esModule:false
}
},
{
test:/\.(woff2?|eot|ttf|otf)$/,
loader:'url-loader',
options:{
limit:10000,
name:'fonts/[name].[ext]'
}
}
]
},
plugins:[
new HtmlWebpackPlugin({
template:'./src/pages/index/index.art',
filename:'index.html'
})
]
};
问题描述:package.json
{
"name": "mall",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --open chrome",
"webpack": "webpack"
},
"author": "",
"license": "ISC",
"dependencies": {
"art-template": "^4.13.2"
},
"devDependencies": {
"art-template-loader": "^1.4.3",
"css-loader": "^4.2.1",
"file-loader": "^6.0.0",
"html-webpack-plugin": "^4.3.0",
"style-loader": "^1.2.1",
"url-loader": "^4.1.0",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0"
}
}
问题描述:index.js
import './css/base.css';
import './css/css.css';
import './css/reset.css';
import './js/backtotop.js';
import './js/carousel.js';
import './js/menu.js';
目录结构跟老师的一样,这里显示html-webpack-plugin这个插件有问题
老师帮忙看下
正在回答 回答被采纳积分+1
相似问题
登录后可查看更多问答,登录/注册
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星