Tôi mới sử dụng webpack, và tôi cần một bàn tay trong việc thiết lập để tạo ra các sourcemaps. Tôi đang chạy webpack serve
từ dòng lệnh, biên dịch thành công. Nhưng tôi thực sự cần sourcemaps. Đây là số webpack.config.js
của tôi.Làm cách nào để tạo các bản đồ nguồn khi sử dụng babel và webpack?
var webpack = require('webpack');
module.exports = {
output: {
filename: 'main.js',
publicPath: '/assets/'
},
cache: true,
debug: true,
devtool: true,
entry: [
'webpack/hot/only-dev-server',
'./src/components/main.js'
],
stats: {
colors: true,
reasons: true
},
resolve: {
extensions: ['', '.js', '.jsx'],
alias: {
'styles': __dirname + '/src/styles',
'mixins': __dirname + '/src/mixins',
'components': __dirname + '/src/components/',
'stores': __dirname + '/src/stores/',
'actions': __dirname + '/src/actions/'
}
},
module: {
preLoaders: [{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'jsxhint'
}],
loaders: [{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'react-hot!babel-loader'
}, {
test: /\.sass/,
loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded&indentedSyntax'
}, {
test: /\.scss/,
loader: 'style-loader!css!sass'
}, {
test: /\.(png|jpg|woff|woff2)$/,
loader: 'url-loader?limit=8192'
}]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
]
};
Tôi thực sự mới với webpack và tìm kiếm các tài liệu chưa thực sự hữu ích vì tôi không chắc vấn đề này cụ thể là gì.
Bạn cũng có thể cần để thêm 'debug: true' để làm việc này. – hughes
Thuộc tính 'denug' đã bị xóa trong webpack 2. – jnns
@jnns Điều gì đã thay thế nó? – Brad