wuhu-torn-helper/rollup.config.js
2023-03-02 18:12:29 +08:00

72 lines
2.4 KiB
JavaScript

// [!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
// src/vue/ItemPrice.vue?vue&type=script&lang.ts (35:13)
// import typescript from "@rollup/plugin-typescript";
import typescript2 from "rollup-plugin-typescript2";
import json from "@rollup/plugin-json";
import html from "rollup-plugin-string-html";
import resolve from "@rollup/plugin-node-resolve";
import replace from "@rollup/plugin-replace";
import alias from "@rollup/plugin-alias";
import postcss from 'rollup-plugin-postcss';
import vue from "@vitejs/plugin-vue";
let node_env = process.env.NODE_ENV;
let vuePath = node_env === 'production' ?
'vue/dist/vue.runtime.esm-browser.prod.js' :
'vue/dist/vue.runtime.esm-browser.js';
export default {
input: 'src/ts/class/Application.ts',
output: {
file: 'dist/bundle.js',
format: 'iife',
name: 'bundle.js',
},
plugins: [
json(),
// 根据环境更改vue源
alias({
entries: [{ find: 'vue', replacement: vuePath }]
}),
// 为vue替换环境变量
replace({
values: {
'process.env.NODE_ENV': () => JSON.stringify(node_env),
'__VUE_OPTIONS_API__': () => JSON.stringify(false),
'__VUE_PROD_DEVTOOLS__': () => JSON.stringify(true),
},
preventAssignment: true,
}),
// 引入node相关方法
resolve({
browser: true,
preferBuiltins: false,
}),
vue({ isProduction: node_env === 'production' }),
// TODO watch模式下vue更新不完全
typescript2({
tsconfig: "tsconfig.json",
// clean: true,
// check: false,
}),
postcss({ minimize: true }),
html({
// include: ["**/*.html", "**/*.css"],
include: ["**/*.html"],
minifier: {
includeAutoGeneratedTags: true,
removeAttributeQuotes: false,
removeComments: true,
removeRedundantAttributes: false,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
sortClassName: true,
useShortDoctype: true,
collapseWhitespace: true,
minifyCSS: true,
}
}),
// typescript(),
],
};