I’m not sure whether I’m correctly understanding output.chunkFilename‘s [name]
. My assumption was that [name]
would match [name]
in output.filename.
Using vue-webpack-example: https://github.com/vuejs/vue-webpack-example
module.exports = {
entry: "./src/main.js",
output: {
path: "./build",
publicPath: "/build/",
filename: "build.js"
},
module: {
loaders: [
{ test: /\.styl$/, loader: "style!css!stylus" },
{ test: /\.html$/, loader: "html" }
]
}
}
Creates the following files:
- build.js
- 1.build.js
- 2.build.js
If I change option.filename to: build.[name].js
module.exports = {
entry: "./src/main.js",
output: {
path: "./build",
publicPath: "/build/",
filename: "build.[name].js"
},
module: {
loaders: [
{ test: /\.styl$/, loader: "style!css!stylus" },
{ test: /\.html$/, loader: "html" }
]
}
}
Creates the following files:
- build.main.js
- 1.build.1.js
- 2.build.2.js
Shouldn’t it create the following files?:
- build.main.js
- 1.build.main.js
- 2.build.main.js
Setting [name] in output.chunkFilename always seems to become the [id]
module.exports = {
entry: "./src/main.js",
output: {
path: "./build",
publicPath: "/build/",
chunkFilename: "[name].[id].js",
filename: "build.[name].js"
},
module: {
loaders: [
{ test: /\.styl$/, loader: "style!css!stylus" },
{ test: /\.html$/, loader: "html" }
]
}
}
Creates the following files:
- 1.1.js
- 2.2.js
- build.main.js
You are mistaking something.
A chunk can be named.
Then, it would build
bundle.jQueryStuff.js
orjQueryStuff.bundle.js
instead.A chunk without a name gets an incrementing ID.
@tilleps The AMD ‘require’ does not allow you to name a chunk, so you need to use the commonjs option. ie change your code to this and you will not get the error
require.ensure([], function(require){
var $ = require(“jquery”) // you may need to add .default here
// Something awesome with jQuery. $
}, “jQueryStuff” // this will be passed webpack template under [name] and can be used with chunkFileName);
I’m trying to deal with this right now and
[name].[name].bundle.js
gives me0.chunk_name.bundle.js
using @psimoneau22 suggestionEdit:
Nevermind, using
ChunkFilename
as an argument to the output worked:This results in:
Whereas before I would get
0.Chunk1.bundle.js
when using[name].[name].bundle.js
as an argument topath
inoutput
Is
chunkFilename
a feature to be used only with code-splitting?Because I’m doing some tests with Webpack (not using code-splitting) and setting any value to
chunkFilename
doesn’t make a difference in my build output.i have
chunckFilename
in my webpack-config but still getting the number like name of bundling of both css chunks and js chunks???? what is going on???