Webpack

React - react-scripts publicPath

时间秒杀一切 提交于 2021-02-20 19:02:10
问题 Is there possibility to override publicPath in react-scripts for dev env. I use symfony and I include react app inside twig so I had to change assets to serve from http://localhost:3000/static/js/bundle.js - this works fine but I have problem with static files because they are rendered in browser as '/static/media/logo.813ua.png' and my current url is http://localhost:8000 What I did is I run yarn eject and modify in webpack.config.dev.js: var publicPath = 'http://localhost:3000/' and

React - react-scripts publicPath

血红的双手。 提交于 2021-02-20 19:00:12
问题 Is there possibility to override publicPath in react-scripts for dev env. I use symfony and I include react app inside twig so I had to change assets to serve from http://localhost:3000/static/js/bundle.js - this works fine but I have problem with static files because they are rendered in browser as '/static/media/logo.813ua.png' and my current url is http://localhost:8000 What I did is I run yarn eject and modify in webpack.config.dev.js: var publicPath = 'http://localhost:3000/' and

Typescript/babel import causing “_1.default is not a function”

心已入冬 提交于 2021-02-20 18:46:58
问题 I am trying to use https://github.com/timmywil/panzoom from a typescript project compiled with webpack and babel. The problem is that the typescript method call: import Panzoom from '@panzoom/panzoom'; Panzoom(document.querySelector("#pic")); is transpiled to the following javascript: panzoom_1.default(document.querySelector("#pic")); which then generates the following run-time error: Uncaught TypeError: panzoom_1.default is not a function If I debug the javascript then panzoom_1 has the

Typescript/babel import causing “_1.default is not a function”

旧巷老猫 提交于 2021-02-20 18:46:55
问题 I am trying to use https://github.com/timmywil/panzoom from a typescript project compiled with webpack and babel. The problem is that the typescript method call: import Panzoom from '@panzoom/panzoom'; Panzoom(document.querySelector("#pic")); is transpiled to the following javascript: panzoom_1.default(document.querySelector("#pic")); which then generates the following run-time error: Uncaught TypeError: panzoom_1.default is not a function If I debug the javascript then panzoom_1 has the

Firebase cloud functions bundled with webpack?

倾然丶 夕夏残阳落幕 提交于 2021-02-20 10:16:55
问题 I've been stuck for a while trying to make a webpack build for my cloud functions files. My project structure: ROOT - FUNCTIONS - DIS - bundle.js // THIS SHOULD BE GENERATED BY WEBPACK - SRC - myCloudFunction.js // SOURCE CODE FOR A CLOUD FUNCTION - entryPoint.js // ENTRY POINT FOR WEBPACK - index.js - package.json - SRC - App.js .babelrc firebase.json webpack.prod.js // THIS BUILDS FOR CLIENT (WORKING FINE) webpack.server.js // THIS SHOULD BUILD FOR THE SERVER (NOT WORKING) My goal is: Write

Firebase cloud functions bundled with webpack?

≡放荡痞女 提交于 2021-02-20 10:16:49
问题 I've been stuck for a while trying to make a webpack build for my cloud functions files. My project structure: ROOT - FUNCTIONS - DIS - bundle.js // THIS SHOULD BE GENERATED BY WEBPACK - SRC - myCloudFunction.js // SOURCE CODE FOR A CLOUD FUNCTION - entryPoint.js // ENTRY POINT FOR WEBPACK - index.js - package.json - SRC - App.js .babelrc firebase.json webpack.prod.js // THIS BUILDS FOR CLIENT (WORKING FINE) webpack.server.js // THIS SHOULD BUILD FOR THE SERVER (NOT WORKING) My goal is: Write

vue首屏优化方案

坚强是说给别人听的谎言 提交于 2021-02-20 01:12:13
前言:最近用vue-cli 3.0 构建一个小型的工单管理系统,完工后build发现一个chunk-vendors包就达到985kb,加上其他一些资源文件,首页的下载总共大小快要2M。测试给的第一个反馈就是首屏慢慢慢慢慢! 根据首屏加载资源文件过大,进行一下优化: 1. 路由懒加载 结合Vue的异步组件再结合webpack的代码分割,我们可以轻松的实现路由懒加载。 ️vue-cli 3.0 模式就使用了Babel,我们需要添加 syntax-dynamic-import 插件,才能使 Babel 可以正确地解析语法。 // 安装插件 syntax-dynamic-import cnpm install --save-dev @babel/plugin-syntax-dynamic-import // 修改babel.config.js module.exports = { "presets": [ "@vue/app" ], "plugins": [ [ "component", { "libraryName": "element-ui", "styleLibraryName": "theme-chalk" }, "syntax-dynamic-import" ] ] } // 修改路由组件的加载(router/index.js) { path: '/', name: 'home'

How do I configure mini-css-extract-plugin in Gatsby?

百般思念 提交于 2021-02-19 08:02:30
问题 The problem When I run npm run build in my Gatsby project, I'm getting multiple warnings of the same kind: warn chunk styles [mini-css-extract-plugin] Conflicting order. Following module has been added: * css ./node_modules/css-loader??ref--12-oneOf-0-1!./node_modules/postcss-loader/src??postcss-4!./node_modules/sass-loader/dist/cjs.j s??ref--12-oneOf-0-3!./src/components/MineralsHeading/MineralsHeading.module.scss despite it was not able to fulfill desired ordering with these modules: * css

Access Environment Variables from SASS in Next.JS

风格不统一 提交于 2021-02-19 06:15:14
问题 I am trying to add a variable to my scss files, referenced to .env variable. To achieve this, I've read a few tutorials, and I found this. I need to add this configuration to my next.config.js const withImages = require('next-images'); module.exports = withImages({ webpack(config, options) { config.module.rules.push({ test: /\.s[ac]ss$/i, use: [ { loader: "css-loader", options: { importLoaders: 2, modules: { compileType: 'module' } } }, { loader: 'sass-loader', options: { additionalData: `

Access Environment Variables from SASS in Next.JS

自作多情 提交于 2021-02-19 06:14:50
问题 I am trying to add a variable to my scss files, referenced to .env variable. To achieve this, I've read a few tutorials, and I found this. I need to add this configuration to my next.config.js const withImages = require('next-images'); module.exports = withImages({ webpack(config, options) { config.module.rules.push({ test: /\.s[ac]ss$/i, use: [ { loader: "css-loader", options: { importLoaders: 2, modules: { compileType: 'module' } } }, { loader: 'sass-loader', options: { additionalData: `