|
@@ -2,9 +2,8 @@ const CopyWebpackPlugin = require("copy-webpack-plugin");
|
|
const AutoImport = require("unplugin-auto-import/webpack");
|
|
const AutoImport = require("unplugin-auto-import/webpack");
|
|
const Components = require("unplugin-vue-components/webpack");
|
|
const Components = require("unplugin-vue-components/webpack");
|
|
const { ElementPlusResolver } = require("unplugin-vue-components/resolvers");
|
|
const { ElementPlusResolver } = require("unplugin-vue-components/resolvers");
|
|
-const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
|
|
-const webpack = require('webpack');
|
|
|
|
-const StringReplacePlugin = require("string-replace-webpack-plugin");
|
|
|
|
|
|
+const ExtReloader = require('webpack-ext-reloader');
|
|
|
|
+
|
|
|
|
|
|
const ReplaceCssPlugin = require("./script/replaceCssPlugin.js");
|
|
const ReplaceCssPlugin = require("./script/replaceCssPlugin.js");
|
|
|
|
|
|
@@ -28,7 +27,16 @@ const plugins = [
|
|
new CopyWebpackPlugin({
|
|
new CopyWebpackPlugin({
|
|
patterns: copyFiles,
|
|
patterns: copyFiles,
|
|
}),
|
|
}),
|
|
-
|
|
|
|
|
|
+ //仅支持webpack4.x 不支持5.x 需要自己手动改造5.x版本
|
|
|
|
+ /* new ExtReloader({
|
|
|
|
+ port: 9091, // Which port use to create the server
|
|
|
|
+ reloadPage: true, // Force the reload of the page also
|
|
|
|
+ entries: { // The entries used for the content/background scripts or extension pages
|
|
|
|
+ contentScript: 'content',
|
|
|
|
+ background: 'background',
|
|
|
|
+ extensionPage: 'popup',
|
|
|
|
+ },
|
|
|
|
+ }), */
|
|
new ReplaceCssPlugin(),
|
|
new ReplaceCssPlugin(),
|
|
AutoImport({
|
|
AutoImport({
|
|
include: [
|
|
include: [
|
|
@@ -78,19 +86,32 @@ chromeName.forEach((name) => {
|
|
});
|
|
});
|
|
|
|
|
|
module.exports = {
|
|
module.exports = {
|
|
|
|
+
|
|
pages,
|
|
pages,
|
|
// 生产环境是否生成 sourceMap 文件
|
|
// 生产环境是否生成 sourceMap 文件
|
|
productionSourceMap: false,
|
|
productionSourceMap: false,
|
|
-
|
|
|
|
|
|
+ /* pluginOptions: {
|
|
|
|
+ 'style-resources-loader': {
|
|
|
|
+ preProcessor: 'less',
|
|
|
|
+ patterns: [path.resolve(__dirname, './src/assets/css/default.less')]
|
|
|
|
+ }
|
|
|
|
+ }, */
|
|
configureWebpack: {
|
|
configureWebpack: {
|
|
// 多入口打包
|
|
// 多入口打包
|
|
entry: {
|
|
entry: {
|
|
content: "./src/content/index.js",
|
|
content: "./src/content/index.js",
|
|
background: "./src/background/index.js",
|
|
background: "./src/background/index.js",
|
|
},
|
|
},
|
|
|
|
+ resolve:{
|
|
|
|
+ alias:{
|
|
|
|
+ '@': path.resolve('src'),
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
output: {
|
|
output: {
|
|
filename: "js/[name].js",
|
|
filename: "js/[name].js",
|
|
},
|
|
},
|
|
|
|
+
|
|
plugins,
|
|
plugins,
|
|
optimization: {
|
|
optimization: {
|
|
splitChunks: {
|
|
splitChunks: {
|
|
@@ -116,10 +137,38 @@ module.exports = {
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
- chainWebpack: (config) => {},
|
|
|
|
|
|
+
|
|
|
|
+ //配置less解析和浏览器自动补全前缀
|
|
|
|
+ chainWebpack: (config) => {
|
|
|
|
+ config.module.rule('less')
|
|
|
|
+ .test(/\.less$/)
|
|
|
|
+ .use('style-loader')
|
|
|
|
+ .loader('style-loader')
|
|
|
|
+ .end()
|
|
|
|
+ .use('css-loader')
|
|
|
|
+ .loader('css-loader')
|
|
|
|
+ .end()
|
|
|
|
+ .use('postcss-loader')
|
|
|
|
+ .loader('postcss-loader')
|
|
|
|
+ .end()
|
|
|
|
+ .use('less-loader')
|
|
|
|
+ .loader('less-loader')
|
|
|
|
+ .end()
|
|
|
|
+ },
|
|
css: {
|
|
css: {
|
|
extract: {
|
|
extract: {
|
|
filename: "css/[name].css",
|
|
filename: "css/[name].css",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
+ /* devServer:{
|
|
|
|
+
|
|
|
|
+ host: '0.0.0.0', // 让你的服务器可以被外部访问
|
|
|
|
+ port: 8080, // 端口
|
|
|
|
+ https: false, // 不使用 HTTP 提供服务
|
|
|
|
+ hot: true,
|
|
|
|
+ onBeforeSetupMiddleware: function(app, server,compiler) {
|
|
|
|
+ // 在服务器启动之前执行的函数
|
|
|
|
+ console.log(compiler,'compilercompilercompiler')
|
|
|
|
+ },
|
|
|
|
+ } */
|
|
};
|
|
};
|