Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

Commit d208e81

Browse files
committed
add package and webpack config
1 parent bb37e56 commit d208e81

File tree

2 files changed

+161
-0
lines changed

2 files changed

+161
-0
lines changed

package.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"name": "laravel-generator-ui",
3+
"description": "Laravel Generator UI",
4+
"main": "index.js",
5+
"keywords": [
6+
"laravel",
7+
"generator",
8+
"ui"
9+
],
10+
"license": "Apache-2.0",
11+
"repository": "git@github.com:tanhongit/laravel-generator-ui.git",
12+
"authors": [
13+
{
14+
"name": "Tan Nguyen",
15+
"email": "tannp27@gmail.com",
16+
"homepage": "https://tanhongit.com"
17+
}
18+
],
19+
"dependencies": {
20+
"acorn": "^8.8.2",
21+
"mini-css-extract-plugin": "^2.7.3",
22+
"postcss": "^8.4.21",
23+
"style-loader": "^3.3.1",
24+
"svgo-loader": "^4.0.0"
25+
},
26+
"devDependencies": {
27+
"@babel/core": "^7.21.0",
28+
"@babel/preset-env": "^7.20.2",
29+
"autoprefixer": "^10.4.14",
30+
"eslint-parser": "^8.0.11",
31+
"babel-loader": "^9.1.2",
32+
"css-loader": "^6.7.3",
33+
"css-minimizer-webpack-plugin": "^4.2.2",
34+
"eslint": "^8.36.0",
35+
"eslint-config-prettier": "^8.7.0",
36+
"eslint-webpack-plugin": "^4.0.0",
37+
"eslint-plugin-jsx-a11y": "^6.7.1",
38+
"eslint-plugin-prettier": "^4.2.1",
39+
"expose-loader": "^4.1.0",
40+
"postcss-loader": "^7.0.2",
41+
"prettier": "^2.8.4",
42+
"sass": "^1.42.1",
43+
"sass-loader": "^12.1.0",
44+
"stylelint": "^13.13.1",
45+
"stylelint-declaration-use-variable": "^1.7.3",
46+
"stylelint-prettier": "^1.2.0",
47+
"stylelint-webpack-plugin": "^4.1.0",
48+
"webpack": "^5.76.1",
49+
"webpack-cli": "^5.0.1",
50+
"webpack-dev-server": "^4.11.1",
51+
"terser-webpack-plugin": "^5.3.7"
52+
},
53+
"scripts": {
54+
"test": "echo \"Error: no test specified\" && exit 1",
55+
"start": "webpack serve --mode development --open",
56+
"dev": "webpack --mode development --watch",
57+
"build": "webpack --mode production"
58+
},
59+
"browserslist": [
60+
"last 2 versions",
61+
"ie >= 1%"
62+
]
63+
}

webpack.config.js

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
const StylelintPlugin = require("stylelint-webpack-plugin");
2+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
3+
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
4+
const TerserPlugin = require("terser-webpack-plugin");
5+
6+
const config = {
7+
entry: {
8+
main: [".src/css/style.css", "./js/main.js"],
9+
editor: {
10+
import: [
11+
'../css/styles.css',
12+
13+
'../js/script.js',
14+
]
15+
}
16+
},
17+
output: {
18+
filename: "[name].js",
19+
},
20+
module: {
21+
rules: [
22+
{
23+
test: /\.css$/,
24+
use: [
25+
{
26+
loader: MiniCssExtractPlugin.loader,
27+
options: {
28+
publicPath: "",
29+
},
30+
},
31+
{
32+
loader: "css-loader",
33+
},
34+
{
35+
loader: "postcss-loader",
36+
},
37+
],
38+
},
39+
{
40+
test: /\.svg/,
41+
type: "asset",
42+
parser: {
43+
dataUrlCondition: {
44+
maxSize: 8192
45+
}
46+
},
47+
use: 'svgo-loader'
48+
},
49+
{
50+
test: /\.png|jpg|gif/,
51+
type: "asset/resource",
52+
},
53+
{
54+
enforce: "pre",
55+
test: /\.js$/,
56+
exclude: [/node_modules/, /vendor/],
57+
loader: "eslint-loader",
58+
options: {
59+
fix: true,
60+
},
61+
},
62+
{
63+
test: /\.js$/,
64+
exclude: /node_modules/,
65+
loader: "babel-loader",
66+
},
67+
],
68+
},
69+
externals: {
70+
jquery: 'jQuery',
71+
},
72+
optimization: {
73+
minimize: true,
74+
minimizer: [
75+
new TerserPlugin({
76+
parallel: true,
77+
terserOptions: {
78+
ecma: 6,
79+
},
80+
}),
81+
new CssMinimizerPlugin()],
82+
},
83+
84+
plugins: [
85+
new StylelintPlugin({
86+
files: ["./**/*.{scss,sass}"],
87+
fix: true,
88+
}),
89+
new MiniCssExtractPlugin(),
90+
],
91+
};
92+
module.exports = (env, argv) => {
93+
argv.mode === "development"
94+
? (config.devtool = "eval-cheap-module-source-map")
95+
: (config.devtool = "source-map");
96+
97+
return config;
98+
};

0 commit comments

Comments
 (0)