这一行 webpack html loader 语法是什么意思?
What does this single line of webpack html loader syntax mean?
为了解决我在 webpack.config.js
文件中遇到的问题,我从 a webpack blog 复制了一行。该行在下面的代码中加了星号。然而,我似乎无法轻易弄清楚这条线在做什么,谷歌搜索并没有让我得到一个简单的解释。那么,指示行的 purpose/syntax 是什么?一个简短的解释可能就足够了,但是 link 一些(官方)文档也会有所帮助。
var path = require('path');
module.exports = {
entry: {
javascript: ['babel-polyfill', './src/main.js'],
html: './index.html'
},
output: {
path: path.join(__dirname, 'build'),
filename: 'bundle.js'
},
devtools: 'inline-source-map',
module: {
loaders: [
{
loader: 'babel-loader',
test: path.join(__dirname, 'src'),
query: {
presets: ['react', 'es2015', 'stage-2']
}
},
{
test: /\.html$/,
loader: 'file?name=[name].[ext]' // <---- **********
}
]
}
};
webpack 文件加载器允许您使用 name=
查询参数为导入的文件指定自定义文件名模板:
Webpack 1 支持完全通过类似 DSL 的查询字符串来配置加载器。以替代语法编写的配置清楚(呃)发生了什么:
{
test: /\.html$/,
loader: 'file', // Use the file loader
query: { // Configuring it with the following options
name: '[name].[ext]'
// Set the name of the HTML files that are output to be
// the local name of the file, followed by a literal dot character
// followed by the file's extension.
}
}
为了解决我在 webpack.config.js
文件中遇到的问题,我从 a webpack blog 复制了一行。该行在下面的代码中加了星号。然而,我似乎无法轻易弄清楚这条线在做什么,谷歌搜索并没有让我得到一个简单的解释。那么,指示行的 purpose/syntax 是什么?一个简短的解释可能就足够了,但是 link 一些(官方)文档也会有所帮助。
var path = require('path');
module.exports = {
entry: {
javascript: ['babel-polyfill', './src/main.js'],
html: './index.html'
},
output: {
path: path.join(__dirname, 'build'),
filename: 'bundle.js'
},
devtools: 'inline-source-map',
module: {
loaders: [
{
loader: 'babel-loader',
test: path.join(__dirname, 'src'),
query: {
presets: ['react', 'es2015', 'stage-2']
}
},
{
test: /\.html$/,
loader: 'file?name=[name].[ext]' // <---- **********
}
]
}
};
webpack 文件加载器允许您使用 name=
查询参数为导入的文件指定自定义文件名模板:
Webpack 1 支持完全通过类似 DSL 的查询字符串来配置加载器。以替代语法编写的配置清楚(呃)发生了什么:
{
test: /\.html$/,
loader: 'file', // Use the file loader
query: { // Configuring it with the following options
name: '[name].[ext]'
// Set the name of the HTML files that are output to be
// the local name of the file, followed by a literal dot character
// followed by the file's extension.
}
}