- 39
- 0
vue-cli3
非生产模式下,配置的东西可以通过output.js可以看到
在生产模式下,配置的东西通过output.js看不到
//我的测试代码
if (IS_PROD) {
config.plugin("webpack-report").use(BundleAnalyzerPlugin, [
{
analyzerMode: "static"
}
]);
}
},
//IS_PROD为false,output.js里面有
new BundleAnalyzerPlugin(
{
analyzerMode: 'static'
}
)
//IS_PROD为true,output.js里面则没有上面的配置
问题:生产模式下,配置的东西通过什么可以看到
我的想法(可能是错的)
output.js对应的应该是webpack.development.config.js
那么webpack.production.config.js有没有对应的文件?
- 共 0 条
- 全部回答
-
是我太轻敌了 普通会员 2楼
The
output.jsfile in a Vue CLI 3 project is responsible for serving and rendering the compiled JavaScript code, which is used by the Vue.js application. Here's an overview of what's contained in theoutput.jsfile:scripts: Thescriptsobject in theoutput.jsfile contains the list of scripts generated by the Vue CLI. Each script represents a single build step or action that the Vue CLI takes to generate a production-ready JavaScript file. Thescriptsobject is specified in the following format:
javascript scripts: { build: 'vue build', serve: 'vue serve', devServer: 'vue-cli-service dev', test: 'vue-cli-service test', buildWebpack: { module: { rules: [ { test: /\.vue$/, loader: 'vue-loader', options: { babel: { presets: ['@vue/babel-preset-env', '@vue/babel-preset-react'], plugins: [ '@vue/babel-plugin-transform-runtime', 'transform-runtime', ['import', { commonjs2, commonjs }], ], }, }, }, { test: /\.js$/, loader: 'babel-loader', options: { presets: ['@vue/babel-preset-env', '@vue/babel-preset-react'], plugins: [ '@vue/babel-plugin-transform-runtime', 'transform-runtime', ['import', { commonjs2, commonjs }], ], }, }, ], }, }, }publicPath: ThepublicPathobject specifies the base URL for static assets (images, stylesheets, etc.) generated by the Vue CLI. This is set to theoutput.publicPathproperty in thepackage.jsonfile. By default, thepublicPathis set tobuild/public:
json "publicPath": "/dist/"However, if you're using a custom build process, you can override the
publicPathproperty to specify a different URL for static assets:json "publicPath": "https://example.com/dist/"index.js: Theindex.jsfile is the entry point for the Vue.js application and serves as the entry point for the JavaScript file that's generated by the Vue CLI. This file defines the module exports and exports any required components or functions from the Vue module.
Here's an example of what the
index.jsfile might look like:```javascript import Vue from 'vue'; import App from './App.vue'; import router from './router'; import { createApp } from '@vue/cli-service'; import 'vue-router/dist/vue-router.esm.js';
const app = createApp(App); app.use(router); app.mount('#app');
export default app; ```
public/index.html: Thepublic/index.htmlfile is the HTML file that serves as the entry point for the Vue.js application. This file includes the Vue instance, the Vue Router instance, and any other JavaScript components or modules required by the application.
Here's an example of what the
public/index.htmlfile might look like:```html
Vue.js App ```
This
public/index.htmlfile includes a Vue instance, a Vue Router instance, and a reference to theindex.jsfile that's generated by the Vue CLI. Thepublic/index.htmlfile is rendered by the Vue Router and is accessible to all pages of the application.package.json: Thepackage.jsonfile contains information about the Vue CLI project, including its dependencies and configuration options. Thescriptssection of thepackage.jsonfile specifies the commands that the Vue CLI takes to build, serve, and run the application. Theoutputsection of thepackage.jsonfile provides additional information about the build process, including the output directory, the public path, and the entry point.
Here's an example of what the
package.jsonfile might look like:json { "name": "my-app", "version": "1.0.0", "description": "A Vue.js application", "main": "index.js", "scripts": { "build": "vue build", "serve": "vue serve", "devServer": "vue-cli-service dev", "test": "vue-cli-service test", "buildWebpack": { module: { rules: [ { test: /\.vue$/, loader: 'vue-loader', options: { babel: { presets: ['@vue/babel-preset-env', '@vue/babel-preset-react'], }, plugins: [ '@vue/babel-plugin-transform-runtime', 'transform-runtime', ['import', { commonjs2, commonjs }], ], }, }, { test: /\.js$/, loader: 'babel-loader', options: { presets: ['@vue/babel-preset-env', '@vue/babel-preset-react'], plugins: [ '@vue/babel-plugin-transform-runtime', 'transform-runtime', ['import', { commonjs2, commonjs }], ], }, }, ], }, }, "dependencies": { "vue": "^3.2.1", "vue-router": "^3.4.1", }, "devDependencies": { "@vue/cli-plugin-babel": "^3.2.0", "@vue/cli-plugin-eslint": "^3.2.0", "@vue/cli-plugin-router": "^3.4.0", "@vue/cli-plugin-vuex": "^3.4.0", "@vue/cli-service": "^3.2.0", "@vue/cli-plugin-tsc": "^3.2.0", "@vue/cli-plugin-webpack": "^3.2.0", "eslint": "^8.4.0", "vue-template-compiler": "^3.2.1", }, }, "keywords": ["vue", "framework", "js", "web", "frontend"], "author": "Your Name", "license": "MIT", }In this example, the
package.jsonfile specifies the following scripts:buildruns thevue buildcommand to generate a production-ready JavaScript file, which is then minified and served to the browser.serveruns thevue servecommand to serve the application on the specified port (e.g.,http://localhost:3000).devServerruns thevue-cli-service devcommand to serve the application on the development server (e.g.,http://localhost:3001).testruns thevue-cli-service testcommand to run the application's unit tests.buildWebpackconfigures the build process to use the@vue/babel-preset-envpreset, which applies the@vue/babel-preset-reactpreset to the JavaScript code. It also includes the@vue/babel-plugin-transform-runtimeplugin to transpile runtime code (e.g., ES modules) into CommonJS modules, and theimportplugin to import CommonJS modules from the main module.dependencies: specifies the dependencies required by the Vue CLI application, including the Vue, Vue Router, and Vuex modules.devDependencies: specifies the dependencies required by the Vue CLI development environment, including the@vue/cli-plugin-babel,@vue/cli-plugin-eslint,@vue/cli-plugin-router,@vue/cli-plugin-vuex,@vue/cli-service,@vue/cli-plugin-tsc, and@vue/cli-plugin-webpackplugins.keywords: specifies a list of keywords that can be used to search for and filter the package, such as "vue", "framework", "js", "web", "frontend".author: specifies the name of the project author.license: specifies the license for the project, such as "MIT".scripts: specifies the scripts that the Vue CLI takes to build, serve, and run the application, as well as the dependencies required by the development environment.
- 扫一扫访问手机版
回答动态

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器更新之后。服务器里面有部分玩家要重新创建角色是怎么回事啊?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题函数计算不同地域的是不能用内网吧?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题ARMS可以创建多个应用嘛?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题在ARMS如何申请加入公测呀?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题前端小程序接入这个arms具体是如何接入监控的,这个init方法在哪里进行添加?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器刚到期,是不是就不能再导出存档了呢?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器的游戏版本不兼容 尝试更新怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器服务器升级以后 就链接不上了,怎么办?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器转移以后服务器进不去了,怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器修改参数后游戏进入不了,是什么情况?预计能赚取 0积分收益
- 回到顶部
- 回到顶部
