https://codesandbox.io/s/qqwx3175kq
create file .browserslistrc with valid browserlist query, say ie 11
in nuxt.config.js enable babel debug mode
presets: ({ isServer }) => [
[
'@nuxt/babel-preset-app',
{
debug: true,
},
],
],
to observe babel config
babel runs with target "ie 11"
babel run with default config "ie 9"
https://github.com/nuxt/nuxt.js/blob/dev/packages/babel-preset-app/src/index.js#L53
probably due to "ie 9" would be used when target is not defined, despite browserlist exists
Not sure whether it's intended to respect the a .browserlistrc or not.
馃
cc @clarkdo
@williamchong007
Since nuxt will set ie9(client) and node: current(server) as default targets, so if you want to use browserlist, please try this for enabling browserslist in client building:
Note: .browserslistrc under configPath (starting point of searching)
build: {
babel: {
presets: ({ isServer }) => {
return [[
'@nuxt/babel-preset-app',
{
buildTarget: isServer ? 'server' : 'client', // for auto import polyfill
targets: isServer ? { node: 'current' } : {},
configPath: __dirname // if cwd is same as dir of .browserslistrc, no need to specify
}
]]
}
}
}
Thanks for the reply
Should I treat this as a temp fix or a long term solution?
@williamchong007
Now, You can use it for sure, and I'll just close this issue 馃槃
About some more appropriate solution, I'll think about it, if you have any suggestions, feel free to comment here.
Most helpful comment
@williamchong007
Since nuxt will set
ie9(client) andnode: current(server) as default targets, so if you want to usebrowserlist, please try this for enabling browserslist in client building:Note:
.browserslistrcunderconfigPath(starting point of searching)