1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- const CopyWebpackPlugin = require('copy-webpack-plugin')
- const webpack = require('webpack')
- const cesiumSource = 'node_modules/cesium/Source'
- const cesiumWorkers = '../Build/Cesium/Workers'
- const path = require("path");
- function resolve(dir) {
- return path.join(__dirname, dir);
- }
- module.exports = {
- publicPath: './', // 基本路径
- outputDir: 'dist', // 构建时的输出目录
- assetsDir: 'static', // 放置静态资源的目录
- indexPath: 'index.html', // html 的输出路径
- filenameHashing: true, // 文件名哈希值
- lintOnSave: false, // 是否在保存的时候使用 `eslint-loader` 进行检查。
-
- // 组件是如何被渲染到页面中的? (ast:抽象语法树;vDom:虚拟DOM)
- // template ---> ast ---> render ---> vDom ---> 真实的Dom ---> 页面
- // runtime-only:将template在打包的时候,就已经编译为render函数
- // runtime-compiler:在运行的时候才去编译template
- runtimeCompiler: false,
-
- transpileDependencies: [], // babel-loader 默认会跳过 node_modules 依赖。
- productionSourceMap: false, // 是否为生产环境构建生成 source map
-
- 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('./')
- })
- ],
- module: {
- unknownContextCritical: false,
- unknownContextRegExp: /\/cesium\/cesium\/Source\/Core\/buildModuleUrl\.js/
- },
- // 配置cesium----开始
- amd: {
- toUrlUndefined: true
- },
- output: {
- sourcePrefix: ' '
- }
- },
- devServer: {
- proxy: {
- '/socket.io':{
- target: 'http://192.168.1.6:1234', // target host
- changeOrigin: true, // needed for virtual hosted sites
- logLevel: 'debug'
- },
- '/sockjs-node': {
- target: 'http://192.168.1.6:1234',
- ws: false,
- changeOrigin: true
- }
-
- }
- },
- chainWebpack: config => {
- config.resolve.alias
- .set("@", resolve("src"))
- .set("assets", resolve("src/assets"))
- .set("components", resolve("src/components"))
- .set("public", resolve("public"))
- .set("cesium",path.resolve(__dirname, cesiumSource))
- // set svg-sprite-loader
- config.module
- .rule('svg')
- .exclude.add(resolve('src/assets')) // 存放 svg 目录的目录
- .end()
- config.module
- .rule('assets')
- .test(/\.svg$/)
- .include.add(resolve('src/assets')) // 存放 svg 目录的目录
- .end()
- .use('svg-sprite-loader')
- .loader('svg-sprite-loader')
- .options({
- symbolId: 'icon-[name]'
- })
- .end()
- }
- }
|