add replace plugin

This commit is contained in:
yehuozhili
2021-10-07 20:10:29 +08:00
parent c37d442b45
commit 8a6f57bcd2
2 changed files with 11 additions and 4 deletions

View File

@@ -2,7 +2,7 @@
* @Author: yehuozhili * @Author: yehuozhili
* @Date: 2021-09-30 09:51:40 * @Date: 2021-09-30 09:51:40
* @LastEditors: yehuozhili * @LastEditors: yehuozhili
* @LastEditTime: 2021-10-07 13:18:49 * @LastEditTime: 2021-10-07 17:51:09
* @FilePath: \dooringx\packages\dooringx-plugin-template\template\rollup.config.js * @FilePath: \dooringx\packages\dooringx-plugin-template\template\rollup.config.js
*/ */
import { DEFAULT_EXTENSIONS } from "@babel/core"; import { DEFAULT_EXTENSIONS } from "@babel/core";
@@ -14,6 +14,7 @@ import resolve from "@rollup/plugin-node-resolve";
import url from "@rollup/plugin-url"; import url from "@rollup/plugin-url";
import svgr from "@svgr/rollup"; import svgr from "@svgr/rollup";
import { terser } from "rollup-plugin-terser"; import { terser } from "rollup-plugin-terser";
import replace from "@rollup/plugin-replace";
import typescriptEngine from "typescript"; import typescriptEngine from "typescript";
import external from "rollup-plugin-peer-deps-external"; import external from "rollup-plugin-peer-deps-external";
const externalPkg = ["react", "react-dom"]; const externalPkg = ["react", "react-dom"];
@@ -29,6 +30,7 @@ export default {
globals: { react: "React", "react-dom": "ReactDom" }, globals: { react: "React", "react-dom": "ReactDom" },
freeze: false, freeze: false,
exports: "default", exports: "default",
sourcemap: true,
}, },
], ],
onwarn: function (warning) { onwarn: function (warning) {
@@ -49,6 +51,10 @@ export default {
external({ external({
includeDependencies: true, includeDependencies: true,
}), }),
replace({
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
preventAssignment: true,
}),
typescript({ typescript({
typescript: typescriptEngine, typescript: typescriptEngine,
include: ["*.js+(|x)", "**/*.js+(|x)"], include: ["*.js+(|x)", "**/*.js+(|x)"],

View File

@@ -7,14 +7,14 @@
"license": "MIT", "license": "MIT",
"main": "index.js", "main": "index.js",
"publishConfig": { "publishConfig": {
"registry": "http://registry.npmjs.org/" "registry": "https://registry.npmjs.org/"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/H5-Dooring/dooringx.git" "url": "git+https://github.com/H5-Dooring/dooringx.git"
}, },
"scripts": { "scripts": {
"build": "rimraf ./dist && rollup -c" "build": "rimraf ./dist && rollup -c --environment NODE_ENV:production"
}, },
"bugs": { "bugs": {
"url": "https://github.com/H5-Dooring/dooringx/issues" "url": "https://github.com/H5-Dooring/dooringx/issues"
@@ -45,7 +45,8 @@
"rollup-plugin-peer-deps-external": "^2.2.4", "rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-postcss": "^4.0.1", "rollup-plugin-postcss": "^4.0.1",
"rollup-plugin-terser": "^7.0.2", "rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0" "rollup-plugin-typescript2": "^0.30.0",
"@rollup/plugin-replace": "^3.0.0"
}, },
"dependencies": {} "dependencies": {}
} }