mirror of https://gitee.com/antv-l7/antv-l7
fix: babel.config.js for gatsby
This commit is contained in:
parent
562a86fdb7
commit
365f0158d1
|
@ -1,6 +1,40 @@
|
||||||
// @see https://babeljs.io/docs/en/next/config-files#project-wide-configuration
|
// @see https://babeljs.io/docs/en/next/config-files#project-wide-configuration
|
||||||
module.exports = (api) => {
|
module.exports = (api) => {
|
||||||
api.cache(() => process.env.NODE_ENV);
|
api.cache(() => process.env.NODE_ENV);
|
||||||
|
if(process.env.NODE_ENV === 'site') {
|
||||||
|
return {
|
||||||
|
"presets": [
|
||||||
|
[
|
||||||
|
"@babel/preset-env",
|
||||||
|
{
|
||||||
|
"loose": true,
|
||||||
|
"modules": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@babel/preset-react',
|
||||||
|
"babel-preset-gatsby"
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
[
|
||||||
|
'@babel/plugin-proposal-decorators',
|
||||||
|
{
|
||||||
|
legacy: true,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
// import glsl as raw text
|
||||||
|
'babel-plugin-inline-import',
|
||||||
|
{
|
||||||
|
extensions: [
|
||||||
|
// 由于使用了 TS 的 resolveJsonModule 选项,JSON 可以直接引入,不需要当作纯文本
|
||||||
|
// '.json',
|
||||||
|
'.glsl',
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
presets: [
|
presets: [
|
||||||
[
|
[
|
||||||
|
@ -14,7 +48,6 @@ module.exports = (api) => {
|
||||||
],
|
],
|
||||||
'@babel/preset-react',
|
'@babel/preset-react',
|
||||||
'@babel/preset-typescript',
|
'@babel/preset-typescript',
|
||||||
'babel-preset-gatsby',
|
|
||||||
],
|
],
|
||||||
plugins: [
|
plugins: [
|
||||||
'@babel/plugin-proposal-optional-chaining',
|
'@babel/plugin-proposal-optional-chaining',
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import './packages/component/src/css/l7.css';
|
require('./packages/component/src/css/l7.css');
|
||||||
// window.GeoTIFF = require('geotiff/dist/geotiff.bundle.js')
|
// window.GeoTIFF = require('geotiff/dist/geotiff.bundle.js')
|
||||||
window.scene = require('./packages/scene/src');
|
window.scene = require('./packages/scene/src');
|
||||||
window.layers= require('./packages/layers/src');
|
window.layers= require('./packages/layers/src');
|
||||||
|
|
|
@ -1,7 +1,17 @@
|
||||||
const setWebpackConfig = require('./.storybook/webpack.config');
|
const path = require('path');
|
||||||
|
|
||||||
exports.onCreateWebpackConfig = ({ getConfig, stage, plugins }) => {
|
exports.onCreateWebpackConfig = ({ getConfig, stage, plugins }) => {
|
||||||
const config = getConfig();
|
const config = getConfig();
|
||||||
config.resolve.extensions.push('.glsl');
|
config.resolve.extensions.push('.glsl');
|
||||||
console.log(config);
|
config.resolve.alias = {
|
||||||
|
...config.resolve.alias,
|
||||||
|
'@l7/core': path.resolve(__dirname, 'packages/core/src'),
|
||||||
|
'@l7/component': path.resolve(__dirname, 'packages/component/src'),
|
||||||
|
'@l7/layers': path.resolve(__dirname, 'packages/layers/src'),
|
||||||
|
'@l7/maps': path.resolve(__dirname, 'packages/maps/src'),
|
||||||
|
'@l7/renderer': path.resolve(__dirname, 'packages/renderer/src'),
|
||||||
|
'@l7/scene': path.resolve(__dirname, 'packages/scene/src'),
|
||||||
|
'@l7/source': path.resolve(__dirname, 'packages/source/src'),
|
||||||
|
'@l7/utils': path.resolve(__dirname, 'packages/utils/src'),
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
"worker-loader": "^2.0.0"
|
"worker-loader": "^2.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "export NODE_ENV=site && npm run site:develop",
|
"start": "NODE_ENV=site npm run site:develop",
|
||||||
"site:develop": "gatsby develop --open -H 0.0.0.0",
|
"site:develop": "gatsby develop --open -H 0.0.0.0",
|
||||||
"site:build": "npm run site:clean && export NODE_ENV=site && gatsby build --prefix-paths",
|
"site:build": "npm run site:clean && export NODE_ENV=site && gatsby build --prefix-paths",
|
||||||
"site:clean": "gatsby clean",
|
"site:clean": "gatsby clean",
|
||||||
|
|
Loading…
Reference in New Issue