bundle-tools
bundle-tools copied to clipboard
Webpack + vue.config.js failed to compile
Reporting a bug?
I've added this to my vue.config.js:
const path = require('path');
const VueI18nPlugin = require('@intlify/unplugin-vue-i18n/webpack');
module.exports = {
configureWebpack: {
plugins: [
VueI18nPlugin({
include: path.resolve(__dirname, './src/locales/**')
})
],
Expected behavior
yarn build should work as before.
Reproduction
https://github.com/Glandos/unplugin-vue-i18n-issue222
- yarn
- yarn serve
Issue Package
unplugin-vue-i18n
System Info
System:
OS: Linux 6.1 Debian GNU/Linux bookworm/sid
CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
Memory: 16.50 GB / 31.21 GB
Container: Yes
Shell: 3.5.1 - /usr/bin/fish
Binaries:
Node: 16.19.0 - /tmp/fnm_multishells/68944_1675784800039/bin/node
Yarn: 3.3.1 - /usr/local/bin/yarn
npm: 8.19.3 - /tmp/fnm_multishells/68944_1675784800039/bin/npm
Browsers:
Chromium: 109.0.5414.119
Firefox: 109.0
npmPackages:
vue: ^2.7.14 => 2.7.14
vue-i18n: ^8.28.2 => 8.28.2
webpack: ^5 => 5.75.0
Screenshot
Error: Child compilation failed:
Module parse failed: Unexpected token (1:0)
File was processed with these loaders:
* ./node_modules/unplugin/dist/webpack/loaders/load.js
* ./node_modules/html-webpack-plugin/lib/loader.js
You may need an additional loader to handle the result of these loaders.
> <!DOCTYPE html>
| <html lang="en" translate="no">
|
Additional context
No response
Validations
- [X] Read the Contributing Guidelines.
- [X] Read the README
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion.
Same is happening to me.
const path = require('path')
const VueI18nPlugin = require('@intlify/unplugin-vue-i18n/webpack')
let exportsObject = {
publicPath: process.env.VUE_APP_STATIC_CONTENT_BASE_URL,
chainWebpack: config => {
const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
types.forEach(type => addStyleResource(config.module.rule('less').oneOf(type)))
},
/* ... */
plugins: [
/* ... */
VueI18nPlugin({
/* options */
// locale messages resourece pre-compile option
include: path.resolve(__dirname, './path/to/src/locales/**'),
})
],
pluginOptions: {
'style-resources-loader': {
preProcessor: 'less',
patterns: []
}
}
}
@michug did you install the module in your project, either:
npm install --save-dev @intlify/unplugin-vue-i18nyarn add -D @intlify/unplugin-vue-i18n
?
Reproduction in https://github.com/Glandos/unplugin-vue-i18n-issue222:
git clone https://github.com/Glandos/unplugin-vue-i18n-issue222.gityarnyarn build
@Glandos
yes, I did npm install --save-dev @intlify/unplugin-vue-i18n
Same issue here, this occurs since version 0.7.0 of @intlify/unplugin-vue-i18n.
Version 0.6.2 and earlier works fine.
Same issue here
I face the same issue;
Cannot find module '@intlify/vite-plugin-vue-i18n' or its corresponding type declarations.
Same here on quasar v2.6.0 with webpack and latest @intlify/unplugin-vue-i18n
// quasar.config.js
build: {
chainWebpack (chain) {
const VueI18nPlugin = require('@intlify/unplugin-vue-i18n/webpack')
chain.plugin('unplugin-vue-i18n').use(VueI18nPlugin).init(() => VueI18nPlugin())
}
}
The error is
Module parse failed: Unexpected token (1:0)
File was processed with these loaders:
* ./node_modules/unplugin/dist/webpack/loaders/load.js
* ./node_modules/html-webpack-plugin/lib/loader.js
You may need an additional loader to handle the result of these loaders.
> <!DOCTYPE html>
| <html>
| <head>
...
And this is the index.template.html that's having problem.
By install an older version of unplugin-vue-i18n (0.6.2), npm install --save-dev @intlify/unplugin-vue-i18n@^0.6.2, thing works again.
same here. Tried version 0.6.2, above error is gone, but I get a parse error on other JSON files (not locales).
Module parse failed: Unexpected token (2:18) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
for me build works with [email protected]
Same issue here. Currently stuck using version 0.7.3. Any version above that gives me the following error:
Error: Child compilation failed:
Module parse failed: Unexpected token (1:0)
File was processed with these loaders:
* ./node_modules/unplugin/dist/webpack/loaders/load.js
* ./node_modules/html-webpack-plugin/lib/loader.js
You may need an additional loader to handle the result of these loaders.
Same issue here.Version 0.7.2 and earlier works fine.
It seems to be due to update [email protected] Since Version 0.8.0.
but older is
Issue still exists in v4.0.0 Reverting to version 0.7.2 as suggested by TianbinTobin resolves the issue