增加wxml解析入口
This commit is contained in:
parent
8330998030
commit
4e8762e6f5
|
|
@ -0,0 +1,13 @@
|
|||
const loaderUtils = require('loader-utils');
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} content 文件信息
|
||||
* @param {*} map 文件映射信息
|
||||
* @param {*} meta 模块的元数据
|
||||
*/
|
||||
module.exports = function (content, map, meta) {
|
||||
// const options = loaderUtils.getOptions(this);
|
||||
// console.log(content, options);
|
||||
return content;
|
||||
};
|
||||
|
|
@ -30,7 +30,7 @@ const relativeFileLoader = (ext = '[ext]') => {
|
|||
};
|
||||
};
|
||||
|
||||
const oakLoader = (ext = '[ext]') => {
|
||||
const oakFileLoader = (ext = '[ext]') => {
|
||||
return {
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
|
|
@ -38,7 +38,7 @@ const oakLoader = (ext = '[ext]') => {
|
|||
name: `[path][name].${ext}`,
|
||||
outputPath: (url, resourcePath, context) => {
|
||||
const outputPath = url.split(
|
||||
'oak-general-business/src/platforms/wechatMp/'
|
||||
'oak-general-business/wechatMp/'
|
||||
)[1];
|
||||
return outputPath;
|
||||
},
|
||||
|
|
@ -66,12 +66,20 @@ module.exports = {
|
|||
'@': SOURCE,
|
||||
assert: require.resolve('assert'),
|
||||
},
|
||||
extensions: ['.ts', '.js', 'json'],
|
||||
extensions: ['.ts', '.js'],
|
||||
symlinks: true,
|
||||
fallback: {
|
||||
crypto: require.resolve('crypto-browserify'),
|
||||
},
|
||||
},
|
||||
resolveLoader: {
|
||||
// 第一种使用别名的方式引入自定义的loader
|
||||
alias: {
|
||||
'wxml-loader': path.resolve(__dirname, 'loaders/wxml-loader.js'),
|
||||
},
|
||||
// 第二种方式选查找自己的loaders文件中有没有这个loader再查找node_modules文件
|
||||
// modules: [path.resolve(__dirname, 'loaders'), 'node_modules'],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
|
|
@ -87,10 +95,16 @@ module.exports = {
|
|||
},
|
||||
{
|
||||
test: /\.less$/,
|
||||
include: /oak-general-business/,
|
||||
include: /oak-general-business\/wechatMp/,
|
||||
// include: [
|
||||
// path.resolve(
|
||||
// process.cwd(),
|
||||
// 'node_modules/oak-general-business/wechatMp'
|
||||
// ),
|
||||
// ],
|
||||
type: 'javascript/auto',
|
||||
use: [
|
||||
oakLoader('wxss'),
|
||||
oakFileLoader('wxss'),
|
||||
{
|
||||
loader: 'less-loader',
|
||||
options: {
|
||||
|
|
@ -118,6 +132,7 @@ module.exports = {
|
|||
// {
|
||||
// test: /\.json$/,
|
||||
// include: /src/,
|
||||
// exclude: /node_modules/,
|
||||
// type: 'asset/resource',
|
||||
// generator: {
|
||||
// filename: `[path][name].[ext]`,
|
||||
|
|
@ -128,11 +143,34 @@ module.exports = {
|
|||
{
|
||||
test: /\.(xml|wxml)$/,
|
||||
include: /src/,
|
||||
type: 'asset/resource',
|
||||
generator: {
|
||||
filename: `[path][name].[ext]`,
|
||||
},
|
||||
// use: [relativeFileLoader('wxml')],
|
||||
// type: 'asset/resource',
|
||||
// generator: {
|
||||
// filename: `[path][name].[ext]`,
|
||||
// },
|
||||
type: 'javascript/auto',
|
||||
use: [
|
||||
relativeFileLoader('wxml'),
|
||||
{
|
||||
loader: 'wxml-loader',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.(xml|wxml)$/,
|
||||
include: /oak-general-business\/wechatMp/,
|
||||
// include: [
|
||||
// path.resolve(
|
||||
// process.cwd(),
|
||||
// 'node_modules/oak-general-business/wechatMp'
|
||||
// ),
|
||||
// ],
|
||||
type: 'javascript/auto',
|
||||
use: [
|
||||
oakFileLoader('wxml'),
|
||||
{
|
||||
loader: 'wxml-loader',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -46,11 +46,3 @@ export interface PackOptionsIgnore {
|
|||
type: string;
|
||||
value: string;
|
||||
}
|
||||
/**
|
||||
* @name oak-cli需要输入的参数
|
||||
* @export
|
||||
* @interface OakInput
|
||||
*/
|
||||
export interface OakInput {
|
||||
mode: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ function tsConfigJsonContent() {
|
|||
},
|
||||
"include": [
|
||||
"./**/*.ts",
|
||||
"scripts/webpack.js"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
"fs-extra": "^10.0.0",
|
||||
"globby": "^11.1.0",
|
||||
"inquirer": "^7.3.3",
|
||||
"loader-utils": "^3.2.0",
|
||||
"mini-css-extract-plugin": "^2.5.3",
|
||||
"postcss-less": "^6.0.0",
|
||||
"progress-bar-webpack-plugin": "^2.1.0",
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ const requiredPath = require('required-path');
|
|||
const pluginName = 'OakWeChatMpPlugin';
|
||||
const OakPagePrefix = '@oak-general-business';
|
||||
const OakPagePath = 'node_modules/oak-general-business/wechatMp/';
|
||||
// const oakPagePathRegExp = /node_modules\/oak-general-business\/src\/platforms\/wechatMp\//;
|
||||
|
||||
function getIsOak(str) {
|
||||
return str.indexOf(OakPagePrefix) === 0;
|
||||
|
|
@ -349,7 +348,7 @@ class OakWeChatMpPlugin {
|
|||
const entries = await globby(patterns, {
|
||||
cwd: this.basePath,
|
||||
nodir: true,
|
||||
realpath: false,
|
||||
realpath: true,
|
||||
ignore: [...extensions.map((ext) => `**/*${ext}`), ...exclude],
|
||||
dot: false,
|
||||
});
|
||||
|
|
@ -370,7 +369,7 @@ class OakWeChatMpPlugin {
|
|||
{
|
||||
cwd: process.cwd(),
|
||||
nodir: true,
|
||||
realpath: false,
|
||||
realpath: true,
|
||||
ignore: [...extensions.map((ext) => `**/*${ext}`), ...exclude],
|
||||
dot: false,
|
||||
}
|
||||
|
|
@ -382,7 +381,7 @@ class OakWeChatMpPlugin {
|
|||
{
|
||||
cwd: process.cwd(),
|
||||
nodir: true,
|
||||
realpath: false,
|
||||
realpath: true,
|
||||
ignore: [...extensions.map((ext) => `**/*${ext}`), ...exclude],
|
||||
dot: false,
|
||||
}
|
||||
|
|
@ -504,7 +503,7 @@ class OakWeChatMpPlugin {
|
|||
const emitAssets = [];
|
||||
for (let entry of this.assetsEntry) {
|
||||
const assets = path.resolve(this.basePath, entry);
|
||||
if (/\.(sass|scss|css|less|styl)$/.test(assets)) {
|
||||
if (/\.(sass|scss|css|less|styl|xml)$/.test(assets)) {
|
||||
continue;
|
||||
}
|
||||
const toTmit = async () => {
|
||||
|
|
@ -539,7 +538,7 @@ class OakWeChatMpPlugin {
|
|||
}
|
||||
for (let entry of this.oakAssetsEntry) {
|
||||
const assets = path.resolve(process.cwd(), entry);
|
||||
if (/\.(sass|scss|css|less|styl)$/.test(assets)) {
|
||||
if (/\.(sass|scss|css|less|styl|xml)$/.test(assets)) {
|
||||
continue;
|
||||
}
|
||||
const toTmit = async () => {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import {
|
|||
projectConfigContentWithWeChatMp,
|
||||
oakConfigContentWithWeChatMp,
|
||||
} from './template';
|
||||
import { PromptInput, OakInput } from './interface';
|
||||
import { PromptInput } from './interface';
|
||||
import { join } from 'path';
|
||||
import inquirer from 'inquirer';
|
||||
import axios from 'axios';
|
||||
|
|
|
|||
|
|
@ -49,13 +49,4 @@ export interface PackOptions {
|
|||
export interface PackOptionsIgnore {
|
||||
type: string,
|
||||
value: string
|
||||
}
|
||||
|
||||
/**
|
||||
* @name oak-cli需要输入的参数
|
||||
* @export
|
||||
* @interface OakInput
|
||||
*/
|
||||
export interface OakInput {
|
||||
mode: string,
|
||||
}
|
||||
|
|
@ -115,7 +115,6 @@ export function tsConfigJsonContent() {
|
|||
},
|
||||
"include": [
|
||||
"./**/*.ts",
|
||||
"scripts/webpack.js"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
|
|
|
|||
Loading…
Reference in New Issue