forked from JonasFranzDEV/gitea-github-migrator
Improved webpack Signed-off-by: Jonas Franz <info@jonasfranz.software>web-ui
parent
a7a8b42c59
commit
79e87b0bb9
@ -0,0 +1,18 @@ |
|||||||
|
package api |
||||||
|
|
||||||
|
import ( |
||||||
|
"strings" |
||||||
|
|
||||||
|
"github.com/gobuffalo/packr" |
||||||
|
) |
||||||
|
|
||||||
|
type BundledFS struct { |
||||||
|
packr.Box |
||||||
|
} |
||||||
|
|
||||||
|
func (fs *BundledFS) Exists(prefix string, filepath string) bool { |
||||||
|
if p := strings.TrimPrefix(filepath, prefix); len(p) < len(filepath) { |
||||||
|
return fs.Has(p) |
||||||
|
} |
||||||
|
return false |
||||||
|
} |
@ -1,18 +0,0 @@ |
|||||||
<!DOCTYPE html> |
|
||||||
<html> |
|
||||||
<head> |
|
||||||
<meta charset="UTF-8" /> |
|
||||||
<title>Gitea Migrator</title> |
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.1/semantic.min.css"/> |
|
||||||
</head> |
|
||||||
<body> |
|
||||||
<div id="example"></div> |
|
||||||
|
|
||||||
<!-- Dependencies --> |
|
||||||
<script src="./node_modules/react/umd/react.development.js"></script> |
|
||||||
<script src="./node_modules/react-dom/umd/react-dom.development.js"></script> |
|
||||||
<script src="./node_modules/semantic-ui-react/dist/umd/semantic-ui-react.min.js"></script> |
|
||||||
|
|
||||||
<!-- Bundles --> |
|
||||||
<script type="text/javascript" src="dist/bundle.js"></script></body> |
|
||||||
</html> |
|
@ -1,65 +1,76 @@ |
|||||||
var HtmlWebPackPlugin = require("html-webpack-plugin"); |
var HtmlWebPackPlugin = require("html-webpack-plugin"); |
||||||
|
var CopyWebpackPlugin = require("copy-webpack-plugin"); |
||||||
|
var HtmlWebpackExternalsPlugin = require("html-webpack-externals-plugin"); |
||||||
|
|
||||||
module.exports = { |
module.exports = { |
||||||
entry: "./src/index.tsx", |
entry: "./src/index.tsx", |
||||||
output: { |
output: { |
||||||
filename: "bundle.js", |
filename: "bundle.js", |
||||||
path: __dirname + "/dist" |
path: __dirname + "/dist" |
||||||
}, |
}, |
||||||
|
|
||||||
// Enable sourcemaps for debugging webpack's output.
|
// Enable sourcemaps for debugging webpack's output.
|
||||||
devtool: "source-map", |
devtool: "source-map", |
||||||
mode: "development", |
mode: "development", |
||||||
|
|
||||||
resolve: { |
resolve: { |
||||||
// Add '.ts' and '.tsx' as resolvable extensions.
|
// Add '.ts' and '.tsx' as resolvable extensions.
|
||||||
extensions: [".ts", ".tsx", ".js", ".json"] |
extensions: [".ts", ".tsx", ".js", ".json"] |
||||||
}, |
}, |
||||||
|
module: { |
||||||
module: { |
rules: [ |
||||||
rules: [ |
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
|
||||||
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
|
{ |
||||||
{ test: /\.tsx?$/, use: [ |
test: /\.tsx?$/, |
||||||
{ |
use: [ |
||||||
loader: 'babel-loader', |
{ |
||||||
options: { |
loader: "babel-loader", |
||||||
babelrc: false, |
options: { |
||||||
plugins: ['react-hot-loader/babel'] |
babelrc: false, |
||||||
} |
plugins: ["react-hot-loader/babel"] |
||||||
}, |
} |
||||||
'awesome-typescript-loader' |
}, |
||||||
] |
"awesome-typescript-loader" |
||||||
}, |
|
||||||
|
|
||||||
{ |
|
||||||
test: /\.html$/, |
|
||||||
use: [ |
|
||||||
{ |
|
||||||
loader: 'html-loader' |
|
||||||
} |
|
||||||
] |
|
||||||
}, |
|
||||||
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
|
|
||||||
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" } |
|
||||||
] |
] |
||||||
}, |
}, |
||||||
|
|
||||||
plugins: [ |
{ |
||||||
new HtmlWebPackPlugin( |
test: /\.html$/, |
||||||
{ |
use: [ |
||||||
template: "./src/index.html", |
{ |
||||||
filename: "./index.html" |
loader: "html-loader" |
||||||
} |
} |
||||||
) |
] |
||||||
], |
}, |
||||||
|
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
|
||||||
|
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" } |
||||||
|
] |
||||||
|
}, |
||||||
|
|
||||||
// When importing a module whose path matches one of the following, just
|
plugins: [ |
||||||
// assume a corresponding global variable exists and use that instead.
|
new HtmlWebPackPlugin({ |
||||||
// This is important because it allows us to avoid bundling all of our
|
template: "./src/index.html", |
||||||
// dependencies, which allows browsers to cache those libraries between builds.
|
filename: "./index.html" |
||||||
externals: { |
}), |
||||||
"react": "React", |
new HtmlWebpackExternalsPlugin({ |
||||||
"react-dom": "ReactDOM", |
externals: [ |
||||||
"semantic-ui-react": "semanticUIReact" |
{ |
||||||
} |
module: "react", |
||||||
}; |
entry: "umd/react.development.js", |
||||||
|
global: "React" |
||||||
|
}, |
||||||
|
{ |
||||||
|
module: "react-dom", |
||||||
|
entry: "umd/react-dom.development.js", |
||||||
|
global: "ReactDOM" |
||||||
|
}, |
||||||
|
{ |
||||||
|
module: "semantic-ui-react", |
||||||
|
entry: "dist/umd/semantic-ui-react.min.js", |
||||||
|
global: "semanticUIReact" |
||||||
|
} |
||||||
|
] |
||||||
|
}), |
||||||
|
new CopyWebpackPlugin([{ from: "assets", to: "assets" }]) |
||||||
|
] |
||||||
|
}; |
||||||
|
Loading…
Reference in new issue