Skip to content

Commit

Permalink
Fix: [arco-scripts/arco-material-doc-site] webpack loader in webpack …
Browse files Browse the repository at this point in the history
…config should wrap `require.resolve` (#44)

* fix: [arco-scripts] all webpack loader wrap require.resolve to make sure loader can be found under arco-scripts

* fix: [arco-meterial-doc-site] all webpack loader wrap require.resolve to make sure loader can be found under arco-meterial-doc-site
  • Loading branch information
lianghx-319 authored Jul 13, 2022
1 parent db4df27 commit 0122729
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
18 changes: 9 additions & 9 deletions packages/arco-material-doc-site/src/config/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ function getEntryConfig() {
function getModuleRuleForCss() {
return [
{
loader: 'style-loader',
loader: require.resolve('style-loader'),
},
{
loader: 'css-loader',
loader: require.resolve('css-loader'),
},
];
}

function getModuleRuleForLess({ cssModule }: { cssModule?: boolean }) {
return [
{
loader: 'style-loader',
loader: require.resolve('style-loader'),
},
{
loader: 'css-loader',
loader: require.resolve('css-loader'),
options: cssModule
? {
modules: {
Expand All @@ -64,7 +64,7 @@ function getModuleRuleForLess({ cssModule }: { cssModule?: boolean }) {
: {},
},
{
loader: 'less-loader',
loader: require.resolve('less-loader'),
options: {
lessOptions: {
javascriptEnabled: true,
Expand Down Expand Up @@ -95,7 +95,7 @@ function generateBaseConfig() {
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
loader: require.resolve('babel-loader'),
options: babelConfig,
},
],
Expand All @@ -104,11 +104,11 @@ function generateBaseConfig() {
test: /\.md$/,
use: [
{
loader: 'babel-loader',
loader: require.resolve('babel-loader'),
options: babelConfig,
},
{
loader: 'arco-markdown-loader',
loader: require.resolve('arco-markdown-loader'),
options: {
demoDir: 'demo',
preprocess: removeMarkdownDemoPart,
Expand All @@ -118,7 +118,7 @@ function generateBaseConfig() {
},
{
test: /\.svg$/,
use: ['@svgr/webpack'],
use: [require.resolve('@svgr/webpack')],
},
{
test: /\.(png|jpg|gif|ttf|eot|woff|woff2)$/,
Expand Down
18 changes: 9 additions & 9 deletions packages/arco-scripts/src/config/webpack/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ function getUse(cssModule) {
: {};
return [
{
loader: 'style-loader',
loader: require.resolve('style-loader'),
},
{
loader: 'css-loader',
loader: require.resolve('css-loader'),
options,
},
{
loader: 'less-loader',
loader: require.resolve('less-loader'),
options: {
javascriptEnabled: true,
},
Expand Down Expand Up @@ -75,11 +75,11 @@ let config = {
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
loader: require.resolve('babel-loader'),
options: babelConfig,
},
{
loader: 'ts-loader',
loader: require.resolve('ts-loader'),
options: getTSLoaderOptions(),
},
],
Expand All @@ -94,23 +94,23 @@ let config = {
sideEffects: true,
use: [
{
loader: 'style-loader',
loader: require.resolve('style-loader'),
},
{
loader: 'css-loader',
loader: require.resolve('css-loader'),
},
],
},
{
test: /\.(png|jpg|gif|ttf|eot|woff|woff2)$/,
loader: 'file-loader',
loader: require.resolve('file-loader'),
options: {
esModule: false,
},
},
{
test: /\.svg$/,
use: ['@svgr/webpack'],
use: [require.resolve('@svgr/webpack')],
},
{
test: lessModuleRegex,
Expand Down
2 changes: 1 addition & 1 deletion packages/arco-scripts/src/config/webpack/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let config = {
rules: [
{
test: /\.tsx?$/,
loader: 'babel-loader',
loader: require.resolve('babel-loader'),
exclude: /node_modules/,
},
],
Expand Down
30 changes: 15 additions & 15 deletions packages/arco-scripts/src/config/webpack/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ function getUse(cssModule, isProduction) {
: {};
return [
{
loader: isProduction ? MiniCssExtractPlugin.loader : 'style-loader',
loader: isProduction ? MiniCssExtractPlugin.loader : require.resolve('style-loader'),
},
{
loader: 'css-loader',
loader: require.resolve('css-loader'),
options,
},
{
loader: 'postcss-loader',
loader: require.resolve('postcss-loader'),
options: {
postcssOptions: {
plugins: ['autoprefixer'],
},
},
},
{
loader: 'less-loader',
loader: require.resolve('less-loader'),
options: {
javascriptEnabled: true,
},
Expand All @@ -62,9 +62,9 @@ const baseConfig = {
{
test: /\.(js|jsx|ts|tsx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
loader: require.resolve('babel-loader'),
options: babelConfig,
// loader: 'esbuild-loader',
// loader: require.resolve('esbuild-loader'),
// options: {
// loader: 'tsx',
// target: 'es2015',
Expand All @@ -74,16 +74,16 @@ const baseConfig = {
test: /\.md$/,
use: [
{
loader: 'babel-loader',
loader: require.resolve('babel-loader'),
options: babelConfig,
// loader: 'esbuild-loader',
// loader: require.resolve('esbuild-loader'),
// options: {
// loader: 'jsx',
// target: 'es2015',
// },
},
{
loader: 'arco-markdown-loader',
loader: require.resolve('arco-markdown-loader'),
options: {
demoDir: 'demo',
babelConfig,
Expand All @@ -93,18 +93,18 @@ const baseConfig = {
},
{
test: /\.svg$/,
use: ['@svgr/webpack'],
use: [require.resolve('@svgr/webpack')],
},
{
test: /\.(png|jpg|gif)$/,
loader: 'file-loader',
loader: require.resolve('file-loader'),
options: {
esModule: false,
},
},
{
test: /\.(ttf|eot|woff|woff2)$/,
loader: 'file-loader',
loader: require.resolve('file-loader'),
options: {
name: 'fonts/[name].[ext]',
esModule: false,
Expand Down Expand Up @@ -150,10 +150,10 @@ const config = {
test: /\.css$/,
use: [
{
loader: 'style-loader',
loader: require.resolve('style-loader'),
},
{
loader: 'css-loader',
loader: require.resolve('css-loader'),
},
],
},
Expand Down Expand Up @@ -205,7 +205,7 @@ const config = {
loader: MiniCssExtractPlugin.loader,
},
{
loader: 'css-loader',
loader: require.resolve('css-loader'),
},
],
},
Expand Down

0 comments on commit 0122729

Please sign in to comment.