123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- const path = require('path');
- const resolve = (dir) => path.join(__dirname, dir);
- const CopyWebpackPlugin = require('copy-webpack-plugin');
- const webpack = require('webpack');
- const cesiumSource = './node_modules/cesium/Source'
- const cesiumWorkers = '../Source/Workers'
- function extendDefaultPlugins(arr) {
- let plug = [
- 'removeDoctype',
- 'removeXMLProcInst',
- 'removeComments',
- 'removeMetadata',
- 'removeEditorsNSData',
- 'cleanupAttrs',
- 'mergeStyles',
- 'inlineStyles',
- 'minifyStyles',
- 'cleanupIDs',
- 'removeUselessDefs',
- 'cleanupNumericValues',
- 'convertColors',
- 'removeUnknownsAndDefaults',
- 'removeNonInheritableGroupAttrs',
- 'removeUselessStrokeAndFill',
- 'removeViewBox',
- 'cleanupEnableBackground',
- 'removeHiddenElems',
- 'removeEmptyText',
- 'convertShapeToPath',
- 'convertEllipseToCircle',
- 'moveElemsAttrsToGroup',
- 'moveGroupAttrsToElems',
- 'collapseGroups',
- 'convertPathData',
- 'convertTransform',
- 'removeEmptyAttrs',
- 'removeEmptyContainers',
- 'mergePaths',
- 'removeUnusedNS',
- 'sortDefsChildren',
- 'removeTitle',
- 'removeDesc'
- ];
- return plug.concat(arr);
- }
- function addStyleResource(rule) {
- rule.use('style-resource')
- .loader('style-resources-loader')
- .options({
- patterns: [
- resolve('src/assets/styles/common/common.less')
- ]
- })
- }
- module.exports = {
- publicPath: "./",
- indexPath: 'index.html',
- outputDir: 'dist',
- assetsDir: 'static',
- lintOnSave: false,
- runtimeCompiler: true,
- parallel: false,
- configureWebpack: {
- plugins: [
- new CopyWebpackPlugin([{ from: path.join(cesiumSource, cesiumWorkers), to: 'Workers' }]),
- new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Assets'), to: 'Assets' }]),
- new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Widgets'), to: 'Widgets' }]),
- new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'ThirdParty/Workers'), to: 'ThirdParty/Workers' }]),
- new webpack.DefinePlugin({
- CESIUM_BASE_URL: JSON.stringify('./')
- }),
- ]
- },
- chainWebpack: (config) => {
- config.resolve.symlinks(true);
- config.plugin('html')
- .tap(args => {
- args[0].title = "智能综合分析系统";
- return args;
- })
-
- config.resolve.alias
- .set("@", resolve("src"))
- .set("@node", resolve("node_modules"))
- .set("@com", resolve("src/components"))
- .set("@assets", resolve("src/assets"))
- .set("@api", resolve("src/api"))
- .set("@store", resolve("src/store"))
- .set("@modeConfig", resolve("public/static/config"))
- .set("@tools", resolve("src/tools"))
- .set("cesium", resolve("node_modules/cesium/Source"));
-
- const types = ['vue-modules', 'vue', 'normal-modules', 'normal'];
- types.forEach(type => addStyleResource(config.module.rule('less').oneOf(type)));
- const metaLoaderRule = config.module.rule('meta-loader');
- metaLoaderRule.test(/\.js$/)
- .use('@open-wc/webpack-import-meta-loader')
- .loader('@open-wc/webpack-import-meta-loader');
-
- config.module
- .rule('svg')
- .exclude.add(resolve('src/assets/icon/svg'))
- .end()
- .exclude.add(resolve('src/assets/icon/svg_fill'))
- .end();
-
- const svgRule = config.module.rule('icons');
- svgRule.test(/\.svg$/)
- .include.add(resolve('src/assets/icon/svg'))
- .end()
- .use('svg-sprite-loader')
- .loader('svg-sprite-loader')
- .options({
- symbolId: 'svg-[name]',
-
-
-
- });
-
-
-
-
-
-
- svgRule.use('svgo-loader').loader('svgo-loader').options({
- plugins: extendDefaultPlugins([{
- name: "removeAttrs",
- params: {
- attrs: 'fill',
- }
- }])
- });
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
- devServer: {
-
- proxy: {
- '/cbk': {
- target: 'https://h5.caibeike.com.cn/',
- changeOrigin: true,
-
-
- pathRewrite: {
- '^/cbk': ''
- }
- },
- '/weather': {
- target: 'http://t.weather.sojson.com/',
- changeOrigin: true,
-
-
- pathRewrite: {
- '^/weather': ''
- }
- },
- '^/current': {
- target: 'http://10.155.32.14:9002',
- changeOrigin: true,
- rewrite: (path) => path.replace(/^\/current/, '')
- },
- },
- open: false,
- }
- }
|