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 CopyWebpackPlugin = require("copy-webpack-plugin"); |
||||
var HtmlWebpackExternalsPlugin = require("html-webpack-externals-plugin"); |
||||
|
||||
module.exports = { |
||||
entry: "./src/index.tsx", |
||||
output: { |
||||
filename: "bundle.js", |
||||
path: __dirname + "/dist" |
||||
}, |
||||
entry: "./src/index.tsx", |
||||
output: { |
||||
filename: "bundle.js", |
||||
path: __dirname + "/dist" |
||||
}, |
||||
|
||||
// Enable sourcemaps for debugging webpack's output.
|
||||
devtool: "source-map", |
||||
mode: "development", |
||||
// Enable sourcemaps for debugging webpack's output.
|
||||
devtool: "source-map", |
||||
mode: "development", |
||||
|
||||
resolve: { |
||||
// Add '.ts' and '.tsx' as resolvable extensions.
|
||||
extensions: [".ts", ".tsx", ".js", ".json"] |
||||
}, |
||||
|
||||
module: { |
||||
rules: [ |
||||
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
|
||||
{ test: /\.tsx?$/, use: [ |
||||
{ |
||||
loader: 'babel-loader', |
||||
options: { |
||||
babelrc: false, |
||||
plugins: ['react-hot-loader/babel'] |
||||
} |
||||
}, |
||||
'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" } |
||||
resolve: { |
||||
// Add '.ts' and '.tsx' as resolvable extensions.
|
||||
extensions: [".ts", ".tsx", ".js", ".json"] |
||||
}, |
||||
module: { |
||||
rules: [ |
||||
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
|
||||
{ |
||||
test: /\.tsx?$/, |
||||
use: [ |
||||
{ |
||||
loader: "babel-loader", |
||||
options: { |
||||
babelrc: false, |
||||
plugins: ["react-hot-loader/babel"] |
||||
} |
||||
}, |
||||
"awesome-typescript-loader" |
||||
] |
||||
}, |
||||
}, |
||||
|
||||
plugins: [ |
||||
new HtmlWebPackPlugin( |
||||
{ |
||||
template: "./src/index.html", |
||||
filename: "./index.html" |
||||
} |
||||
) |
||||
], |
||||
{ |
||||
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" } |
||||
] |
||||
}, |
||||
|
||||
// When importing a module whose path matches one of the following, just
|
||||
// assume a corresponding global variable exists and use that instead.
|
||||
// This is important because it allows us to avoid bundling all of our
|
||||
// dependencies, which allows browsers to cache those libraries between builds.
|
||||
externals: { |
||||
"react": "React", |
||||
"react-dom": "ReactDOM", |
||||
"semantic-ui-react": "semanticUIReact" |
||||
} |
||||
}; |
||||
plugins: [ |
||||
new HtmlWebPackPlugin({ |
||||
template: "./src/index.html", |
||||
filename: "./index.html" |
||||
}), |
||||
new HtmlWebpackExternalsPlugin({ |
||||
externals: [ |
||||
{ |
||||
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