fe-star / showcase5 Goto Github PK
View Code? Open in Web Editor NEW展台5: webpack
展台5: webpack
在尝试case/loader这个例子的时候发现一直报这个错误:
纠结了半天,最后感谢文坚老师给出解决方法:别用windows。
开个玩笑,其实是因为showcase里面,在写路径的时候用了unix的写法,直接通过字符串拼接出路径,而这个写法在windows下是行不通的,会出现匪夷所思的斜杠换了个方向。在windows下只能通过path.join拼接路径。在windows下 path.join( __dirname , '/src')
与__dirname +'/src'
的区别如下:
// 留意src前斜杠的方向
C:\Users\bin\Desktop\FE_course\showcase5\cases\loader\src
C:\Users\bin\Desktop\FE_course\showcase5\cases\loader/src
因此解决办法就是将__dirname +'/src'
改成 path.join( __dirname , '/src')
。完整代码如下:
const path = require('path')
module.exports = {
entry:path.join( __dirname , '/src'),
module: {
rules: [
{
test: /\.js$/,
include: path.join( __dirname , '/src'),
use: 'babel-loader'
}
]
},
output: {
path: path.join(__dirname , '/dist'),
filename: 'bundle.js'
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.