Skip to content

Commit

Permalink
Fix content-sass example not working
Browse files Browse the repository at this point in the history
  • Loading branch information
cezaraugusto committed Aug 19, 2024
1 parent 46b1201 commit 65b64c8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 43 deletions.
2 changes: 1 addition & 1 deletion examples/action-chatgpt/action/ActionApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function ActionApp() {
'Hello there! This is your ChatGPT extension sample, ' +
'built with React, Tailwind.css, and DaisyUI. ' +
'For it to work, create a .env file with your EXTENSION_OPENAI_API_KEY. ' +
"You can get an API key from OpenAI's website.",
"You can get an API key from OpenAI's website????",
role: 'assistant'
},
{
Expand Down
9 changes: 1 addition & 8 deletions programs/develop/webpack/plugin-css/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {type DevOptions} from '../../commands/dev'
import {maybeUseSass} from './css-tools/sass'
import {maybeUseLess} from './css-tools/less'
import {maybeUseStylelint} from './css-tools/stylelint'
import {getAssetFilename} from '../webpack-config'

export class CssPlugin {
public static readonly name: string = 'plugin-css'
Expand All @@ -29,13 +28,7 @@ export class CssPlugin {
const projectPath = path.dirname(this.manifestPath)

const plugins: WebpackPluginInstance[] = [
new MiniCssExtractPlugin({
chunkFilename: (pathData: PathData) => {
const runtime = (pathData.chunk as any)?.runtime

return getAssetFilename(runtime)
}
})
new MiniCssExtractPlugin()
]

plugins.forEach((plugin) => plugin.apply(compiler))
Expand Down
22 changes: 2 additions & 20 deletions programs/develop/webpack/plugin-static-assets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,11 @@ export class StaticAssetsPlugin {
}

public async apply(compiler: Compiler) {
const getAssetFilename = (folderPath: string) => {
return `${folderPath}/[name][ext]`
}

// Define the default SVG rule
const defaultSvgRule: RuleSetRule = {
test: /\.svg$/i,
type: 'asset/resource',
generator: {
filename: () => getAssetFilename('assets')
},
parser: {
dataUrlCondition: {
// inline images < 2 KB
Expand All @@ -49,9 +43,6 @@ export class StaticAssetsPlugin {
{
test: /\.(png|jpg|jpeg|gif|webp|avif|ico|bmp)$/i,
type: 'asset/resource',
generator: {
filename: () => getAssetFilename('assets')
},
parser: {
dataUrlCondition: {
// inline images < 2 KB
Expand All @@ -61,17 +52,11 @@ export class StaticAssetsPlugin {
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
generator: {
filename: () => getAssetFilename('assets')
}
type: 'asset/resource'
},
{
test: /\.(txt|md|csv|tsv|xml|pdf|docx|doc|xls|xlsx|ppt|pptx|zip|gz|gzip|tgz)$/i,
type: 'asset/resource',
generator: {
filename: () => getAssetFilename('assets')
},
parser: {
dataUrlCondition: {
// inline images < 2 KB
Expand All @@ -81,10 +66,7 @@ export class StaticAssetsPlugin {
},
{
test: /\.(csv|tsv)$/i,
use: [require.resolve('csv-loader')],
generator: {
filename: () => getAssetFilename('assets')
}
use: [require.resolve('csv-loader')]
}
]

Expand Down
14 changes: 0 additions & 14 deletions programs/develop/webpack/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ import {CompatibilityPlugin} from './plugin-compatibility'
import {ErrorsPlugin} from './plugin-errors'
import {BrowsersPlugin} from '../plugin-browsers'

export const getAssetFilename = (folderPath: string) => {
return `${folderPath}/[name][ext]`
}

export default function webpackConfig(
projectPath: string,
devOptions: DevOptions
Expand Down Expand Up @@ -62,16 +58,6 @@ export default function webpackConfig(
bigIntLiteral: true,
dynamicImport: true
},
chunkFilename: (pathData) => {
const runtime = (pathData.chunk as any)?.runtime

// Chunks are stored within their caller's directory,
// So a dynamic import of a CSS action page will be stored
// as action/[filename].css.
// The JS counterpart of this is defined in MiniCssExtractPlugin
// options.chunkFilename function.
return getAssetFilename(runtime)
}
},
resolve: {
modules: ['node_modules', path.join(projectPath, 'node_modules')],
Expand Down

0 comments on commit 65b64c8

Please sign in to comment.