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

webpack.config.js that optionally supports typescript .ts files via ts-loader #1131

Merged
merged 6 commits into from
Jul 14, 2018
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions generators/assets/webpack/templates/webpack.config.js.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const configurator = {
return
}

let key = entry.replace(/(\.\/assets\/(js|css|go)\/)|\.(js|s[ac]ss|go)/g, '')
if(key.startsWith("_") || (/(js|s[ac]ss|go)$/i).test(entry) == false) {
let key = entry.replace(/(\.\/assets\/(src|js|css|go)\/)|\.(ts|js|s[ac]ss|go)/g, '')
if(key.startsWith("_") || (/(ts|js|s[ac]ss|go)$/i).test(entry) == false) {
return
}

Expand All @@ -34,7 +34,6 @@ const configurator = {

entries[key].push(entry)
})

return entries
},

Expand All @@ -43,7 +42,7 @@ const configurator = {
new CleanObsoleteChunks(),
new Webpack.ProvidePlugin({$: "jquery",jQuery: "jquery"}),
new MiniCssExtractPlugin({filename: "[name].[contenthash].css"}),
new CopyWebpackPlugin([{from: "./assets",to: ""}], {copyUnmodified: true,ignore: ["css/**", "js/**"] }),
new CopyWebpackPlugin([{from: "./assets",to: ""}], {copyUnmodified: true,ignore: ["css/**", "js/**", "src/**"] }),
new Webpack.LoaderOptionsPlugin({minimize: true,debug: false}),
new ManifestPlugin({fileName: "manifest.json"})
];
Expand All @@ -62,6 +61,7 @@ const configurator = {
{ loader: "sass-loader", options: {sourceMap: true}}
]
},
{ test: /\.tsx?$/, use: "ts-loader", exclude: /node_modules/},
{ test: /\.jsx?$/,loader: "babel-loader",exclude: /node_modules/ },
{ test: /\.(woff|woff2|ttf|svg)(\?v=\d+\.\d+\.\d+)?$/,use: "url-loader"},
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,use: "file-loader" },
Expand All @@ -79,7 +79,10 @@ const configurator = {
entry: configurator.entries(),
output: {filename: "[name].[hash].js", path: `${__dirname}/public/assets`},
plugins: configurator.plugins(),
module: configurator.moduleOptions()
module: configurator.moduleOptions(),
resolve: {
extensions: ['.ts', '.js', '.json']
}
}

if( env === "development" ){
Expand All @@ -104,4 +107,4 @@ const configurator = {
}
}

module.exports = configurator.buildConfig()
module.exports = configurator.buildConfig()