NuxtjsでIE11対応をするために、@nuxt/babel-preset-appをカスタムしました。
すると、yarn devで表示しようとすると、下記のようなエラーが画面に表示され進みません。
@nuxt/babel-preset-appの公式サイト(Github)を参考に手を尽くしましたがエラーが解消されず・・
ご教授願いたいです...。
nuxt.config.js
js
1module.exports = { 2 mode: 'universal', 3 4 head: { 5 title: 'XXXX', 6 meta: [ 7 {charset: 'utf-8'}, 8 {name: 'viewport', content: 'width=device-width, initial-scale=1'}, 9 {hid: 'description', name: 'description', content: 'Nuxt.js project'}, 10 {name: 'robots', content: 'noindex,nofollow'} 11 ] 12 }, 13 14 srcDir: 'client/', 15 16 modules: [ 17 '@nuxt/http', 18 '@nuxtjs/style-resources' 19 ], 20 21 css: [ 22 'normalize.css/normalize.css', 23 '~/assets/styles/myNormalize.css', 24 '~/assets/styles/customAntDesignStyles.css' 25 ], 26 27 http: { 28 baseURL: 'https://api.thedogapi.com/v1/', 29 }, 30 31 plugins: [ 32 '@/plugins/ant-design-vue', 33 ], 34 35 render: { 36 compressor: false, 37 }, 38 39 build: { 40 extractCSS: true, 41 postcss: { 42 plugins: [ 43 require('postcss-preset-env')({ 44 features: { 45 'nesting-rules': true, 46 } 47 }), 48 require('postcss-custom-properties')(), 49 require('postcss-nested')() 50 ] 51 }, 52 babel: { // このプロパティを追加したらエラー発生 53 presets({envName}) { 54 const envTargets = { 55 client: {browsers: ["last 2 versions"], ie: 11}, 56 server: {node: "current"}, 57 } 58 return [ 59 [ 60 '@nuxt/babel-preset-app', 61 { 62 targets: envTargets[envName], 63 corejs: {version: 3} 64 } 65 ] 66 ] 67 } 68 } 69 } 70}; 71
package.json
json
1{ 2 "name": "aws-node-vue-nuxt-ssr", 3 "version": "1.0.0", 4 "description": "Sample project for using Nuxt.js to create a server-side rendered Vue.js app on AWS Lambda and AWS API Gateway. Can easily integrate with your own API or 3rd party APIs such as headless CMS, e-commerce or serverless architecture.", 5 "main": "index.js", 6 "engines": { 7 "node": ">=8.10" 8 }, 9 "scripts": { 10 "test": "echo \"Error: no test specified\" && exit 1", 11 "dev": "nuxt", 12 "build": "nuxt build", 13 "start": "nuxt start", 14 "generate": "nuxt generate", 15 "deploy": "npm run build && sls deploy", 16 "start-server": "npm run build && node app.js", 17 "start-sls": "npm run build && sls offline start" 18 }, 19 "keywords": [], 20 "author": "", 21 "license": "MIT", 22 "dependencies": { 23 "@nuxt/http": "^0.1.2", 24 "@nuxtjs/babel-preset-app": "nuxt/babel-preset-app", 25 "@nuxtjs/style-resources": "^1.0.0", 26 "ant-design-vue": "^1.4.0-beta.0", 27 "axios": "^0.18.0", 28 "core-js": "^3.2.1", 29 "lodash": "^4.17.15", 30 "moment": "^2.24.0", 31 "normalize.css": "^8.0.1", 32 "nuxt": "^2.9.2", 33 "nuxt-start": "^2.6.3", 34 "postcss-custom-properties": "^9.0.2", 35 "postcss-nested": "^4.1.2", 36 "postcss-preset-env": "^6.7.0", 37 "serverless-apigw-binary": "^0.4.4", 38 "serverless-http": "^2.0.1", 39 "vuex": "^3.1.1" 40 }, 41 "devDependencies": { 42 "serverless-domain-manager": "^3.2.1", 43 "serverless-offline": "^4.10.0" 44 } 45}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。