-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from DauMoe/dev
Merge new code base into master
- Loading branch information
Showing
14 changed files
with
4,319 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
dist | ||
.vscode | ||
sprite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "sprite_png_example", | ||
"version": "0.0.1", | ||
"main": "index.js", | ||
"scripts": { | ||
"serve": "webpack serve --config webpack.config.js", | ||
"build": "webpack --config webpack.config.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "https://github.com/DauMoe", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@babel/core": "^7.0.0", | ||
"@babel/polyfill": "^7.12.1", | ||
"@babel/preset-env": "^7.0.0", | ||
"@babel/preset-react": "^7.14.5", | ||
"babel-loader": "^9.1.3", | ||
"css-loader": "^3.4.0", | ||
"file-loader": "^6.2.0", | ||
"html-webpack-plugin": "^5.3.2", | ||
"react": "^17.0.2", | ||
"react-dom": "17.0.1", | ||
"react-refresh": "^0.14.0", | ||
"style-loader": "^1.1.2", | ||
"webpack": "^5.90.3", | ||
"webpack-cli": "^4.3.0", | ||
"webpack-dev-server": "^4.15.1" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from "react"; | ||
|
||
const CompOne = () => { | ||
return ( | ||
<div>Iam component 1</div> | ||
) | ||
} | ||
|
||
export default CompOne; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
import { getIcon } from "./sprite/getIcon"; | ||
|
||
// import ABC from "./another/test_1.png"; | ||
// import AccountRemove from "./another/test_2.png"; | ||
// import Account from "./another/test_3.png"; | ||
// import ABC_1 from "./media/test_4.png"; | ||
// import transparent from "./media/transparent.png"; | ||
|
||
const AppElement = () => { | ||
const icon1 = getIcon(".png"); | ||
return ( | ||
<div> | ||
<p>Tes_1</p> | ||
<img src={icon1.url} width={icon1.width} height={icon1.height} /> | ||
</div> | ||
); | ||
}; | ||
const root = document.querySelector("body"); | ||
ReactDOM.render( | ||
<AppElement />, | ||
root | ||
); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
const path = require("path"); | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const SpritePNG = require("../index"); | ||
|
||
const subStylePaths = []; | ||
|
||
const setupCacheGroups = () => { | ||
return subStylePaths.reduce((acc, cur) => { | ||
acc[cur.name] = { | ||
name: cur.name, | ||
test: (m, c, entry = cur.name) => { | ||
return m.constructor.name === 'CssModule' && recursiveIssuer(m) === entry; | ||
}, | ||
chunks: 'all', | ||
enforce: true | ||
}; | ||
return acc; | ||
}, {}); | ||
}; | ||
|
||
const sourcePath = path.resolve(__dirname, 'src'); | ||
const isProd = false; | ||
|
||
module.exports = { | ||
mode: isProd ? "production" : "development", | ||
entry: { | ||
bundle: ['@babel/polyfill', path.resolve(sourcePath, './index.js')], | ||
}, | ||
output: { | ||
path: path.join(__dirname, "dist"), | ||
publicPath: '/', | ||
filename: '[name].js', | ||
assetModuleFilename: `./assets/[name][ext]`, | ||
}, | ||
optimization: { | ||
splitChunks: { | ||
cacheGroups: setupCacheGroups() | ||
}, | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(?:js|mjs|cjs)$/, | ||
exclude: /node_modules/, | ||
loader: "babel-loader", | ||
options: { | ||
presets: [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
targets: "defaults" | ||
} | ||
] | ||
] | ||
} | ||
}, | ||
{ | ||
test: /\.png$/, | ||
type: 'asset/resource', | ||
} | ||
] | ||
}, | ||
stats: { | ||
errors: true, | ||
errorStack: true, | ||
errorDetails: true, // --display-error-details | ||
}, | ||
plugins: [ | ||
new HtmlWebpackPlugin({ | ||
filename: "index.html", | ||
template: "index.html" | ||
}), | ||
new SpritePNG({ | ||
entry: [ 'src/media/**/*.png', 'src/another/**/*'], | ||
excludes: /.*\/src\/another\/test_gl\.png$/, | ||
outputDir: "./src/sprite" | ||
}) | ||
], | ||
devServer: { | ||
static: { | ||
directory: path.join(__dirname, 'dist'), | ||
}, | ||
compress: true, | ||
port: 9000, | ||
}, | ||
}; |
Oops, something went wrong.