有人可以给我明确说明如何在我的React应用程序中使用Webpack 3获取绝对路径吗?我似乎无法让它工作。我正在使用create-react-app,如果有帮助,下面是我的webpack配置:
const path = require('path');
module.exports = {
// the directory that contains the entry files.
context: __dirname,
// The point points to enter the application.
entry: './src/index.js',
// path for the output bundle
output: {
path: path.join(__dirname, '/public'),
filename: 'bundle.js',
},
// run webpack on all files with these extensions
resolve: {
extensions: ['.js', '.json'],
},
// webpack output stats
stats: {
colors: true,
reasons: true,
chunks: true,
},
// file loader rules
module: {
loaders: [
path.resolve(__dirname, 'src/'),
],
rules: [
{
exclude: /node_modules/,
test: /\.js$/,
loader: 'babel-loader',
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
],
},
};
我应该在我的webpack配置中添加什么以及我应该在反应js文件中导入/要求什么?