123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- const { defineConfig } = require("@vue/cli-service");
- const linariaLessLoader = require("@queenjs/webpack-loader/linaria-loader");
- const modifyVars = require("./src/styles/theme-antd");
- const path = require("path");
- const {
- CKEditorTranslationsPlugin,
- } = require("@ckeditor/ckeditor5-dev-translations");
- const { styles } = require("@ckeditor/ckeditor5-dev-utils");
- const publicPath =
- process.env.NODE_ENV === "production"
- ? `//infishwaibao.oss-cn-chengdu.aliyuncs.com/queenshowv1/`
- : "./";
- // const publicPath = "./";
- module.exports = defineConfig({
- pages: {
- index: "src/pages/website/index.ts",
- editor: "src/pages/editor/index.ts",
- share: "src/pages/share/h5/index.ts",
- local: "src/pages/share/local/index.ts",
- treeapi: "src/pages/queentree/index.ts",
- },
- publicPath: publicPath,
- transpileDependencies: [/ckeditor5-[^/\\]+[/\\]src[/\\].+\.js$/],
- devServer: {
- client: {
- overlay: {
- errors: true,
- warnings: false,
- runtimeErrors: false,
- },
- },
- },
- configureWebpack: {
- plugins: [
- // CKEditor 5 needs its own plugin to be built using webpack.
- // new CKEditorTranslationsPlugin({
- // See https://ckeditor.com/docs/ckeditor5/latest/features/ui-language.html
- // language: "zh-cn",
- // Append translations to the file matching the `app` name.
- // translationsOutputFile: /ckeditor/,
- // }),
- ],
- },
- chainWebpack: (config) => {
- const tsRule = config.module.rule("ts");
- tsRule
- .use("moduse-loader")
- .loader("moduse/webpack-loader")
- .options({
- include: [
- path.resolve(__dirname, "./src/modules"),
- path.resolve(__dirname, "./node_modules/@queenjs-modules"),
- ],
- });
- const tsxRule = config.module.rule("tsx");
- tsxRule.uses.store.delete("thread-loader");
- tsxRule
- .use("@linaria/webpack-loader")
- .loader("@linaria/webpack-loader")
- .options({
- // 将.css文件更名为.less
- extension: ".linaria.less",
- preprocessor: linariaLessLoader("@/styles/theme"),
- })
- .before("ts-loader");
- const svgRule = config.module.rule("svg");
- // Then you can either:
- //
- // * clear all loaders for existing 'svg' rule:
- //
- // svgRule.uses.clear();
- //
- // * or exclude ckeditor directory from node_modules:
- svgRule.exclude.add(path.join(__dirname, "node_modules", "@ckeditor"));
- // Add an entry for *.svg files belonging to CKEditor. You can either:
- //
- // * modify the existing 'svg' rule:
- //
- // svgRule.use( 'raw-loader' ).loader( 'raw-loader' );
- //
- // * or add a new one:
- config.module
- .rule("cke-svg")
- .test(/ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/)
- .use("raw-loader")
- .loader("raw-loader");
- // (2.) Transpile the .css files imported by the editor using PostCSS.
- // Make sure only the CSS belonging to ckeditor5-* packages is processed this way.
- config.module
- .rule("cke-css")
- .test(/ckeditor5-[^/\\]+[/\\].+\.css$/)
- .use("postcss-loader")
- .loader("postcss-loader")
- .tap(() => {
- return {
- postcssOptions: styles.getPostCssConfig({
- themeImporter: {
- themePath: require.resolve("@ckeditor/ckeditor5-theme-lark"),
- },
- minify: true,
- }),
- };
- });
- },
- css: {
- loaderOptions: {
- less: {
- lessOptions: {
- modifyVars,
- javascriptEnabled: true,
- },
- },
- },
- },
- pluginOptions: {
- windicss: {
- scan: {
- dirs: ["node_modules/@queenjs-modules"],
- fileExtensions: ["tsx"],
- },
- preflight: false,
- onOptionsResolved: (options) => {
- // make sure file @apply's get transformed
- options.scanOptions.extraTransformTargets = {
- css: [
- (f) => {
- if (/node_modules\\@queenjs-modules\\.+\.(css|less)/.test(f)) {
- return true;
- }
- return false;
- },
- ],
- detect: [],
- };
- return options;
- },
- },
- },
- });
|