mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-30 23:06:10 +03:00
Clean up repeated code.
This commit is contained in:
parent
5b39c9f46c
commit
ffc324b21f
@ -8,97 +8,7 @@ const CopyPlugin = require("copy-webpack-plugin");
|
||||
|
||||
module.exports = { start, run };
|
||||
function start() {
|
||||
const compiler = webpack({
|
||||
// webpack options
|
||||
// entry: "index.html",
|
||||
entry: "./index.js",
|
||||
mode: "development",
|
||||
plugins: [
|
||||
new HTMLWebpackPlugin({}),
|
||||
new CopyPlugin([
|
||||
{
|
||||
from: "static/**/*",
|
||||
transformPath(targetPath, absolutePath) {
|
||||
// TODO this is a hack... how do I do this with proper config of `to` or similar?
|
||||
return targetPath.substring(targetPath.indexOf("/") + 1);
|
||||
}
|
||||
}
|
||||
])
|
||||
],
|
||||
output: {
|
||||
publicPath: "/"
|
||||
},
|
||||
resolve: {
|
||||
modules: [path.join(__dirname, "src"), "node_modules"],
|
||||
extensions: [".js", ".elm", ".scss", ".png", ".html"],
|
||||
symlinks: false
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
// loader: "babel-loader"
|
||||
loader: require.resolve("babel-loader")
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.scss$/,
|
||||
exclude: [/elm-stuff/, /node_modules/],
|
||||
// see https://github.com/webpack-contrib/css-loader#url
|
||||
loaders: ["style-loader", "css-loader?url=false", "sass-loader"]
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
exclude: [/elm-stuff/, /node_modules/],
|
||||
loaders: ["style-loader", "css-loader?url=false"]
|
||||
},
|
||||
{
|
||||
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
||||
exclude: [/elm-stuff/, /node_modules/],
|
||||
loader: "url-loader",
|
||||
options: {
|
||||
limit: 10000,
|
||||
mimetype: "application/font-woff"
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
||||
exclude: [/elm-stuff/, /node_modules/],
|
||||
loader: "file-loader"
|
||||
},
|
||||
{
|
||||
test: /\.(jpe?g|png|gif|svg|html)$/i,
|
||||
exclude: [/elm-stuff/, /node_modules/],
|
||||
loader: "file-loader"
|
||||
},
|
||||
{
|
||||
test: /\.elm$/,
|
||||
exclude: [/elm-stuff/, /node_modules/],
|
||||
use: [
|
||||
{ loader: require.resolve("elm-hot-webpack-loader") },
|
||||
{
|
||||
loader: require.resolve("elm-webpack-loader"),
|
||||
options: {
|
||||
// add Elm's debug overlay to output?
|
||||
debug: false,
|
||||
forceWatch: true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
// compiler.watch({}, (error, stats) => {
|
||||
// if (error) {
|
||||
// console.log("error", error);
|
||||
// } else {
|
||||
// console.log("Running!", stats);
|
||||
// }
|
||||
// });
|
||||
|
||||
const compiler = webpack(webpackOptions());
|
||||
const app = express();
|
||||
|
||||
app.use(middleware(compiler, { publicPath: "/" }));
|
||||
@ -122,12 +32,14 @@ function start() {
|
||||
);
|
||||
// https://stackoverflow.com/questions/43667102/webpack-dev-middleware-and-static-files
|
||||
// app.use(express.static(__dirname + "/path-to-static-folder"));
|
||||
|
||||
// compiler.run();
|
||||
}
|
||||
|
||||
function run() {
|
||||
const compiler = webpack({
|
||||
webpack(webpackOptions()).run();
|
||||
}
|
||||
|
||||
function webpackOptions() {
|
||||
return {
|
||||
// webpack options
|
||||
// entry: "index.html",
|
||||
entry: "./index.js",
|
||||
@ -209,7 +121,5 @@ function run() {
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
compiler.run();
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user